-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
121 lines (102 loc) · 3.34 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<title>ECEpic</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body onkeydown="testEchap(event)">
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=ecepic;charset=utf8', 'root', '');
}
catch (Exception $e)
{
die('Erreur : ' . $e->getMessage());
}
?>
<?php
session_start();
if(isset($_POST['formconnexion']))
{
$pseudo=$_POST['pseudo'];
$mdp=$_POST['mdp'];
if(!empty($_POST['pseudo']) && !empty($_POST['mdp']))
{
$check_pseudo = $bdd->prepare('SELECT pseudo, mdp FROM users WHERE pseudo = ?');
$check_pseudo->execute(array($pseudo));
$pseudo_exist = $check_pseudo->rowCount();
if($pseudo_exist == 1)
{
$info_user = $check_pseudo->fetch();
if($info_user['mdp'] == sha1($mdp))
{
session_start();
$_SESSION['user'] = $pseudo;
$message = "Vous êtes connecté!";
header('Location: espace_perso.php');
exit();
}
else
$message = "Mot de passe incorrect";
}
else
$message = "L'utilisateur n'existe pas";
}
else
$message = "Veuillez remplir tous les champs";
}
?>
<?php
if(isset($_POST['deconnexion']))
{
session_destroy();
}
?>
<h1>Bienvenue sur ECEpic!</h1>
<div class='cadre'>
<h2>Connexion: </h2>
<form method="POST" action="">
<table id="form_connexion">
<tr>
<td>
<label>Pseudo: </label>
</td>
<td>
<input type="text" name="pseudo" />
</td>
</tr>
<tr>
<td>
<label>Mot de passe: </label>
</td>
<td>
<input type="password" name="mdp"/>
</td>
</tr>
<tr>
<td></td>
<td>
<input value="Se connecter" type="submit" name="formconnexion"/>
</td>
</tr>
<tr>
<td></td>
<td>
<?php
if(isset($message))
{
echo($message);
}
?>
</td>
</tr>
</table>
</form>
<p class='lien'>Login de l'administrateur: admin</p>
<p class='lien'>Mot de passe de l'administrateur: admin</p>
<p class='lien'>Pas encore inscrit? Clique <a href="inscription.php">ici</a></p>
</div>
</body>
</html>