-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_keycheck.php
106 lines (79 loc) · 1.92 KB
/
mail_keycheck.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
<!-- Check the mail givem by the user -->
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/menu.css">
<link rel="stylesheet" href="css/mail_keycheck.css">
<meta name="viewport" content="width=device-width, user-scalable=yes" />
<link rel="stylesheet" href="fonts/css/font-awesome.min.css">
<title>Camagru</title>
</head>
<body>
<?php
$rootname = getcwd();
require_once($rootname.'/nav/menu.php');
menu();
?>
<div id="redirect">
<p> <?php
require_once('config/function_sql.php');
require_once('function/redirect.php');
function verif_account($username,$bdd)
{
$verif = $bdd->prepare(
"SELECT mail_key FROM `cam_users` WHERE login = :username ");
$verif->execute(array(
'username' => $username
));
$result_verif = $verif->fetch(PDO::FETCH_ASSOC);
if($result_verif['mail_key'] === "1")
{
echo ("Account already verified");
redirect("login.php");
exit();
}
}
$connect = connectToDatabase();
if(!$connect)
exit();
if( !$_GET || !$_GET['uname'] || !$_GET['rkey'])
exit();
verif_account($_GET['uname'],$connect);
$id = $connect->prepare(
"SELECT mail_check FROM `cam_users` WHERE login = :username"
);
$id->execute(array(
'username' => $_GET['uname']
));
$result_id = $id->fetch(PDO::FETCH_ASSOC);
function validate_account($username,$bdd)
{
$validate = $bdd->prepare(
"UPDATE `cam_users` SET `mail_key` = '1' WHERE login = :username ");
$validate->execute(array(
'username' => $username
));
if($validate){
echo ("Account Successfully Verified");
redirect("login.php");
}
else
echo ("An error Occured");
}
if ($result_id['mail_check'] === $_GET['rkey'])
validate_account($_GET['uname'],$connect);
else
echo("An error Occured");
?></p>
</div>
</body>
<?php
$rootname = getcwd();
require_once($rootname.'/script/script.php');
script();
?>
</html>