forked from Kccorp/PA_2021_ESGI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeConf.php
77 lines (54 loc) · 1.92 KB
/
CodeConf.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
<?php
include "header.php";
?>
<div class="container">
<div class="row">
<div class="box shadow border col-md-4 p-3 my-5">
<h1 class="text-green" style="font-family: Roboto" > PLAY </h1>
<h4 class="font-weight-bolder"> Se connecter </h4>
<?php
if( count($_POST)==1 && !empty($_POST["code"]) ){
//Afficher OK si les identifiants sont bons sinon afficher NOK
//password_verify
$code = trim($_POST["code"]);
if (isset($_SESSION["info"]["email"])) {
$email = $_SESSION["info"]["email"];
}else {
$email = $_SESSION["email"];
}
$connection = connectDB();
$queryPrepared = $connection->prepare("SELECT * FROM ".PRE."User WHERE Email=:login");
$queryPrepared->execute(["login"=>$email]);
$results = $queryPrepared->fetch(PDO::FETCH_ASSOC);
if($results["Confcode"]!=$code){
echo '<div class="alert alert-danger">Code incorrect</div>';
}else if( $results["Confcode"] == $code ){
$queryPrepared = $connection->prepare("UPDATE ".PRE."User SET `Check`=:check WHERE email=:email");
$queryPrepared->execute(["check"=>1, "email"=>$email]);
$_SESSION["auth"]=true;
$_SESSION["info"]=$results;
echo '<div class="alert alert-sucess">Connexion réussie</div>';
header("Location: Profil.php");
}else{
echo '<div class="alert alert-danger">Identifiants incorrects</div>';
}
}
?>
<form method="POST">
<div class="row">
<div class="offset-md-1 col-md-10 my-4 mb-2">
<input type="text" class="form-control" name="code" placeholder="Code de confirmation">
</div>
</div>
<div class="row">
<div class="form-check offset-md-4 col-md-4 align mb-4">
<button type="submit" class="btn btn-primary center">Valider</button>
</div>
</div>
</form>
</div>
</div>
</div>
<?php
include "footer.php";
?>