-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnexion.php
More file actions
119 lines (96 loc) · 4.01 KB
/
connexion.php
File metadata and controls
119 lines (96 loc) · 4.01 KB
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
<?php
session_start();
$ip_bloquee = '172.16.1.10';
$ip_visiteur = $_SERVER['REMOTE_ADDR'];
if ($ip_visiteur === $ip_bloquee) {
http_response_code(403);
die('Accès refusé');
}
?>
<?php
if (!empty($_SESSION['user'])){
header('Location: /');
exit();
}
include_once './db/variables.php';
if ($_SERVER['REQUEST_METHOD'] == "POST"){
$message = '';
$email_user = $_POST['email'];
$password_user = $_POST['password'];
if (empty($email_user) || empty($password_user)){
$message = 'Email ou password pas defini';
}else {
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM adherent WHERE adh_mail = :email");
$stmt->bindParam(':email', $email_user);
$stmt->execute();
$resultat = $stmt->fetch();
if ($resultat){
if ($resultat['adh_mail'] == $email_user ){
// $hashpassword = password_hash($password_user, PASSWORD_DEFAULT);
if (password_verify($password_user, $resultat['adh_password'])) {
$message = "Mot de passe correct";
$_SESSION['user'] = [
'id' => $resultat['adh_licence'],
'adh_licence' => $resultat['adh_licence'],
'mail' => $resultat['adh_mail'],
'nom' => $resultat['adh_nom'],
'prenom' => $resultat['adh_prenom'],
'adh_avatar' => $resultat['adh_avatar'],
'admin' => $resultat['admin']
];
header('Location: /');
exit();
}else {
$message = "Mot de passe ou identifiant incorrect";
}
}
// $message = "Connection reussi!";
}else {
$message = "Aucun utilisateur avec cette email existe";
}
$conn = null;
} catch (PDOException $e) {
$message = "Echec de l'affichage :" . $e->getMessage();
}
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="Course, Running">
<meta name="description" content="Devenez adhérents à des courses à pied">
<meta name="author" content="QUEIROZ Florian">
<meta name="viewport" content="width=device-width">
<title>Club de course à pied</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/pages/Connexion.css">
<link rel="shortcut icon" href="../media/favicon.png" type="image/x-icon">
</head>
<body>
<?php
include './components/header.php';
?>
<div class="div-form-flex-container">
<!-- -->
<form action="/connexion.php" method="post">
<?php
if (!empty($message)){
echo '<p> ' . $message . '</p>';
}
?>
<h2>Hello 👋,De retour pour battre votre <span>record</span> ?</h2>
<input type="email" name="email" id="email" placeholder="exemple@btsciel.lan">
<input type="password" name="password" id="password" placeholder="mot de passe">
<button type="submit">Se connecter</button>
</form>
</div>
<?php
include './components/footer.php';
?>
</body>
</html>