-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
39 lines (30 loc) · 1009 Bytes
/
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
<?php
//To Handle Session Variables on This Page
session_start();
//Including Database Connection From db.php file to avoid rewriting in all files
require_once("db.php");
if(isset($_GET)) {
//Escape Special Characters In String First
$hash = mysqli_real_escape_string($conn, $_GET['token']);
$email = mysqli_real_escape_string($conn, $_GET['email']);
//sql query to check if email already exists or not
$sql = "SELECT * FROM users WHERE email='$email' AND hash='$hash'";
$result = $conn->query($sql);
//if email not found then we can insert new data
if($result->num_rows > 0) {
$row = $result->fetch_assoc();
if($row['active'] == '1') {
echo 'You Have Already Activated Your Account';
} else {
$sql1 = "UPDATE users SET active='1' WHERE email='$email' AND hash='$hash'";
if($conn->query($sql1)) {
$_SESSION['userActivated'] = true;
header("Location: login.php");
exit();
}
}
} else {
echo "Token Mismatch";
//you can redirect them to homepage also.
}
}