-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_email.php
41 lines (33 loc) · 1.5 KB
/
verify_email.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
<?php
session_start();
require_once 'config/db.php';
require_once 'controller/sendEmails.php';
if (isset($_GET['token'])) {
$token = $_GET['token'];
$sql = "SELECT * FROM users WHERE token='$token' LIMIT 1";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$user = mysqli_fetch_assoc($result);
$query = "UPDATE users SET verified=1 WHERE token='$token'";
if (mysqli_query($conn, $query)) {
$email = $user['email'];
$username = $user['username'];
$preRole = $user['preRole'];
$userid = $user['userid'];
sendVerificationEmailToAdmin($email, $userid, $preRole, $username);
$_SESSION['username'] = $user['username'];
$_SESSION['userrole'] = $user['userrole'];
$_SESSION['verified'] = true;
$_SESSION['error_message'] = "A mail has been sent to your email account from <b>[email protected]</b>.
Please verrify your account from your email.";
$_SESSION['registered_message'] = "Your email has been successfully verified.";
$_SESSION['wait_message'] = "Please wait as admin verifies your identity and assign you a role as per the preferred user role you chose. Contact Admin if this process takes more than 24hours.";
$_SESSION['alert-class'] = "alert-warning";
header("location: verified.php");
} else {
echo "User not found!";
}
} else {
echo "No token provided!";
}
}