-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthentification.php
101 lines (82 loc) · 2.67 KB
/
authentification.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
<?php
session_start();
include_once('header.php');
require_once "config.php";
// define variables and set to empty values
$loginErr = $mdpErr = "";
$login = $mdp = "";
$idredac;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["login"])) {
$loginErr = "Precisez votre login";
}
if (empty($_POST["mdp"])) {
$mdpErr = "Precisez votre mot de passe";
}
}
if (isset($_POST['submit'])) {
if (empty($loginErr) && empty($mdpErr)) {
$query = "
SELECT * FROM redacteur
WHERE ( pseudo = :username OR adressemail = :username)
AND motdepasse = :mdp";
$statement = $objPdo->prepare($query);
$statement->bindValue(":username", $_POST["login"], PDO::PARAM_STR);
$statement->bindValue(":mdp", $_POST["mdp"], PDO::PARAM_STR);
$statement->bindColumn(1, $id);
$statement->execute();
// while ($statement->fetch(PDO::FETCH_BOUND)){
// print $id;
// }
foreach ($statement as $row) {
$idredac = $id;
$_SESSION["id"] = $idredac;
}
if (isset($idredac)) {
$_SESSION['login'] = true;
header("Location: index.php");
} else {
$errorAuthent = '<label style="
position: fixed;
color: red;
display: block;
left: 50em;
top:20em;
width: 20em; ">Mot de passe ou identifiant incorrecte ! </label>';
}
////////////////////////////////
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="css/mainstyle.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap" rel="stylesheet">
<title>Connect Account</title>
</head>
<body>
<h2 class="page-header--sec">Connexion a un compte de redacteur</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<label class="modif-label">Pseudo(ou e-mail): </label><input class="modif-input" type="text" name="login" value="<?php echo $login; ?>">
<span class="error-log">* <?php echo $loginErr; ?></span>
<br><br>
<label class="modif-label">Mot de Passe:</label> <input class="modif-input" type="password" name="mdp" value="<?php echo $mdp; ?>">
<span class="error-log">* <?php echo $mdpErr; ?></span>
<br><br>
<div class="btn-connect">
<input type="submit" class="btn" name="submit" value="Se Connecter">
</div>
<div class="error-log">
<?php
if (isset($errorAuthent)) {
echo $errorAuthent;
}
?>
</div>
</form>
<button type="button" class="btn exit" onclick="document.location.href='index.php'">Retour</button>
</body>
</html>