-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_email.php
64 lines (59 loc) · 2.31 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Verification</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3 class="text-center">Email Verification</h3>
</div>
<div class="card-body">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="POST">
<div class="form-group">
<label for="email">Enter your email address:</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary btn-block">Verify Email</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
session_start();
require_once 'config.php';
// Check if the form is submitted
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Validate email input
if (isset($_POST['email'])) {
$email = $_POST['email'];
// Check if the email exists in the users table
$stmt = $conn->prepare("SELECT id FROM users WHERE email = ?");
if ($stmt) {
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$_SESSION['email_verified'] = true;
header("Location: start_test.php?course_id=" . $_SESSION['course_id']);
exit();
} else {
echo '<div class="alert alert-danger mt-3">Email not found. Please try again.</div>';
}
$stmt->close();
} else {
echo '<div class="alert alert-danger mt-3">Database error: ' . $conn->error . '</div>';
}
}
}
?>