-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_verify.php
58 lines (52 loc) · 2.18 KB
/
email_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
<?php
session_start();
if (isset($_GET['email'], $_GET['id']))
{
include('connection.php');
$token = bin2hex(random_bytes(16));
$email = trim($_GET['email']);
$id = trim($_GET['id']);
$email = mysqli_real_escape_string($conn, $email);
$id = mysqli_real_escape_string($conn, $id);
$sql = mysqli_query($conn, "SELECT email_verified FROM user WHERE email='$email' AND email_verified = '0'");
$r = mysqli_num_rows($sql);
if ($r > 0)
{
$sql = mysqli_query($conn, "SELECT * FROM user WHERE email='$email' AND forgot_password ='$id' AND status='allowed'");
$r = mysqli_num_rows($sql);
if ($r > 0)
{
$sql = mysqli_query($conn, "UPDATE user SET email_verified = '1' WHERE email= '$email' AND forgot_password ='$id' ");
$success_message = "Email Verification Successful";
//After Verification Email changing id to prevent user
$sql = mysqli_query($conn, "UPDATE user SET forgot_password = '$token' WHERE email= '$email' ");
date_default_timezone_set("Asia/Kolkata");
$login_time = date('Y-m-d H:i:s');
mysqli_query($conn, "UPDATE user SET last_login = '$login_time' WHERE email ='$email'");
$_SESSION['user'] = $email;
echo '<SCRIPT type="text/javascript">
alert("Email Verification Successful.\n Now you are redirecting to Dashboard");
window.location.replace("https://localhost/Faculty-Evaluation-Management-System/user/index.php");
</SCRIPT>';
}
else
{
echo '<script language="javascript">
alert("Email Verification Failed.\n May be due to the following reason\nLink Expired or\nYou are blocked by Admin.");
</script>';
}
}
else
{
echo '<script language="javascript">
alert("Your Email is already verified");
</script>';
}
}
else
{
echo '<script language="javascript">
alert("Email Verification Failed");
</script>';
}
?>