-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.php
84 lines (60 loc) · 2.23 KB
/
login.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
<?php
session_start();
include( "config.php" );
if(isset($_POST['formconnexion'])) {
$mailconnect = htmlspecialchars($_POST['mailconnect']);
$mdpconnect = sha1($_POST['mdpconnect']);
if(!empty($mailconnect) AND !empty($mdpconnect)) {
$requser = $bdd->prepare("SELECT * FROM users WHERE mail = ? AND password = ?");
$requser->execute(array($mailconnect, $mdpconnect));
$userexist = $requser->rowCount();
if($userexist == 1) {
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['pseudo'] = $userinfo['name'];
$_SESSION['mail'] = $userinfo['mail'];
header("Location: index.php?id=".$_SESSION['id']);
} else {
$erreur = "Email address or password is invalid !";
}
} else {
$erreur = "All fields should be completed !";
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<body class="align">
<div class="grid">
<form method="POST" action="" class="form login">
<header class="login__header">
<img src="https://lossantospolicedepartmentlspd.weebly.com/uploads/2/5/6/4/25644844/6606452.png">
<h3 class="login__title">LSPD Login</h3>
</header>
<div class="login__body">
<div class="form__field">
<input type="email" name="mailconnect" placeholder="eMail">
</div>
<div class="form__field">
<input type="password" name="mdpconnect" placeholder="password">
</div>
</div>
<footer class="login__footer">
<input type="submit" value="Login" name="formconnexion">
<p><span class="icon icon--info">?</span><a href="#">Forgot your password</a></p>
</footer>
</form>
<?php
if(isset($erreur)) {
echo '<font color="red">'.$erreur."</font>";
}
?>
</div>
</body>
</body>
</html>