-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivateEmail.php
96 lines (68 loc) · 2.38 KB
/
activateEmail.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
<?php
//------------------------------>> CENTRALIZED TECHFEST NAME WITH YEAR
require_once "config/techfestName.php";
//------------------------------>> DB CONFIG
require_once "config/configPDO.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php $techfestName?> | ACTIVATE ACCOUNT</title>
<!-- Include Header Scripts -->
<?php include_once "includes/headerScripts.php";?>
</head>
<body>
<?php
if (isset($_GET['token'])) {
try {
# Avoid XSS Attack
$token = htmlspecialchars($_GET['token']);
$login = "login.php";
# Query
$sql = "SELECT * FROM user_information WHERE token = :token";
# Preparing Query
$result = $conn->prepare($sql);
# Binding Values
$result->bindValue(":token", $token);
# Executing Query
$result->execute();
$row = $result->fetch(PDO::FETCH_ASSOC);
$dbtokenDate = strtotime($row['tokenDate']);
$currentDatetime = date("Y-m-d H:i:s");
$currentDatetimeMain = strtotime($currentDatetime);
# Checking Wether token time expired or not.
if ($dbtokenDate >= $currentDatetimeMain) {
$sql1 = "UPDATE user_information SET status = :active WHERE token = :token";
$result1 = $conn->prepare($sql1);
$result1->bindValue(":active", "active");
$result1->bindValue(":token", $token);
$result1->execute();
if ($result1) {
echo "<script>Swal.fire({
icon: 'success',
title: 'Account is Activated',
text: 'Your account is successfully activated, Please Login to Continue',
footer: '<a href = $login >Go to the Login Page</a>'
})</script>";
}
} else {
echo "<script>Swal.fire({
icon: 'warning',
title: 'Token Time Expire',
text: 'Please Register Again',
footer: '<a href = $login >Go to the Login Page</a>'
})</script>";
}
} catch (PDOException $e) {
echo "<script>alert('We are sorry, there seems to be a problem with our systems. Please try again.');</script>";
# Development Purpose Error Only
echo "Error " . $e->getMessage();
}
}
?>
<!-- Close Database Connection -->
<?php $conn = null;?>
</body>
</html>