-
Notifications
You must be signed in to change notification settings - Fork 0
/
Begin.php
54 lines (46 loc) · 1.04 KB
/
Begin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
function Connect_db(){
$host="iutdoua-webetu.univ-lyon1.fr";
$user="p1403498";
$password="212840";
$bdname="p1403498";
try{
$bdd = new PDO('mysql:host='.$host.';dbname='.$bdname.
';charset=utf8',$user,$password);
return $bdd;
}
catch(Exception $e)
{
die('Erreur: ' .$e->getMessage());
}
}
function isConnected(){
if (isset($_COOKIE['email']) && isset($_COOKIE['pwd']))
{
$bdd = Connect_db();
$query = $bdd->prepare('SELECT email, password FROM Membre');
$query->execute();
while ($line = $query->fetch())
{
if ($line['email'] == $_COOKIE['email']
&& $line['password'] == $_COOKIE['pwd'])
{
return true;
}
}
}
return false;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>php Events</title>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<a href="accueil.php">Accueil</a>
<?php echo (isConnected()?'<a href="profil.php">Profil</a> <a href="deconnexion.php">Déconnexion</a>':'<a href="connexion.php">Connexion</a>');?>
</header>