-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
74 lines (52 loc) · 2.06 KB
/
verify.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
<?php
session_start();
include_once 'inc/dbconnect.php';
$currentPage = basename(__FILE__);
$errorType = "";
$errorMsg = "";
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
// Verify data
$email = mysqli_escape_string($conn, $_GET['email']); // Set email variable
$hash = mysqli_escape_string($conn, $_GET['hash']); // Set hash variable
$sqql = "SELECT userEmail, activation FROM users WHERE userEmail='".$email."' AND activation='".$hash."'";
$search = mysqli_query($conn, $sqql);
$match = $search->num_rows;
if($match > 0){
// We have a match, activate the account
mysqli_query($conn, "UPDATE users SET activation='activated' WHERE userEmail='".$email."' AND activation='".$hash."'");
$errorType = "success";
$errorMsg = "Your account has been activated, you can now login";
}else{
// No match -> invalid url or account has already been activated.
$errorType = "danger";
$errorMsg = "The url is either invalid or you already have activated your account";
}
}else{
// Invalid approach
$errorType = "danger";
$errorMsg = "Invalid approach, please use the link that has been sent to your email";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'inc/head.php' ?>
<title>Email Verification</title>
</head>
<body>
<div class="wrapper">
<?php include 'inc/navbar.php' ?>
<div class="push"></div>
<div class="container">
<div class="alert alert-<?php echo ($errorType=="success") ? "success" : $errorType; ?>">
<span class="glyphicon glyphicon-info-sign"></span>
<?php echo $errorMsg; ?>
</div>
</div>
<div class="push"></div>
</div>
<footer class="container-fluid text-center">
<p>All rights reserved</p>
</footer>
</body>
</html>