-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.php
More file actions
55 lines (49 loc) · 1.88 KB
/
verify.php
File metadata and controls
55 lines (49 loc) · 1.88 KB
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
<?php
require_once 'Database.php'; // Include the Database class
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$verification_code = trim($_POST['verification_code']);
$email = trim($_POST['email']); // Retrieve email to verify against
// Create a database connection
$database = new Database();
$db = $database->dbConnection();
// Check the verification code in the database
$query = "SELECT * FROM users WHERE email = :email AND verification_code = :verification_code";
$stmt = $db->prepare($query);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':verification_code', $verification_code);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Code is valid, mark user as verified
$query = "UPDATE users SET verification_code = NULL WHERE email = :email";
$stmt = $db->prepare($query);
$stmt->bindParam(':email', $email);
$stmt->execute();
echo "Email verified successfully!";
} else {
echo "Invalid verification code.";
}
}
?>
<!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://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Email Verification</h2>
<form action="verify.php" method="POST">
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Your Email" required>
</div>
<div class="form-group">
<input type="text" class="form-control" name="verification_code" placeholder="Verification Code" required>
</div>
<button type="submit" class="btn btn-primary btn-block">Verify</button>
</form>
</div>
</body>
</html>