-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalidateAccount.php
82 lines (56 loc) · 1.87 KB
/
validateAccount.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
<?php
include('templates/header.php');
include("database/connection.php");
// session_start();
if($_SERVER["REQUEST_METHOD"] == "GET")
{
if (isset($_GET['codeValidate'])){
$code = $_GET['codeValidate'];
$utilizadore = '';
if (isset($_SESSION['username']))
$utilizadore = $_SESSION['username'];
else if (isset($_GET['username']))
$utilizadore = $_GET['username'];
if ($utilizadore != ''){
$stmt = $db->prepare('SELECT RegCode FROM Utilizador WHERE username = :user');
$stmt->bindParam(':user',$utilizadore, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetch();
/*echo $result[0];
echo '<br>';
echo $code;*/
if($result[0] == $code) {
?>
<div id="errorMessage">
<h1>Your account has been validated!</h1>
</div>
<?
$_SESSION['activated'] = 1;
$stmt = $db->prepare('UPDATE Utilizador SET Active=1 WHERE username = :user');
$stmt->bindParam(':user',$utilizadore, PDO::PARAM_STR);
$stmt->execute();
header('Location: polls_index.php?err=validated');
}
else {
//echo "Invalid code. Account not validated";
?>
<div id="errorMessage">
<h1>Wrong Code</h1>
</div>
<?
}
}
}
}
?>
<center>
<div id="validatemodal" >
<h1>Validate your account</h1>
<form id="loginform" name="loginform" method="get" action="">
<label for="username">Verification Code:</label>
<input type="text" name="codeValidate" id="code" class="txtfield" tabindex="1">
<div class="center"><input type="submit" name="submit" id="loginbtn" class="flatbtn-blu hidemodal" value="Validate" tabindex="2"></div>
</form>
</div>
</center>
<? include('templates/footer.php'); ?>