-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverification.php
More file actions
101 lines (85 loc) · 3.63 KB
/
verification.php
File metadata and controls
101 lines (85 loc) · 3.63 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php session_start() ?>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="style.css">
<link rel="icon" href="Favicon.png">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<title>Verification</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light navbar-laravel">
<div class="container">
<a class="navbar-brand" href="#">Verification Account</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<main class="login-form">
<div class="cotainer">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Verification Account</div>
<div class="card-body">
<form action="#" method="POST">
<div class="form-group row">
<label for="email_address" class="col-md-4 col-form-label text-md-right">OTP Code</label>
<div class="col-md-6">
<input type="text" id="otp" class="form-control" name="otp_code" required autofocus>
</div>
</div>
<div class="col-md-6 offset-md-4">
<input type="submit" value="Verify" name="verify">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
</body>
</html>
<?php
require 'connect/connection.php'; // Ensure this file defines $pdo
$database = new connection(); // Create a connection instance
$pdo = $database->getConnection(); // Retrieve the PDO connection
if (isset($_POST["verify"])) {
$otp = $_SESSION['otp'] ?? null;
$email = $_SESSION['mail'] ?? null;
$otp_code = $_POST['otp_code'];
if (!$otp || !$email) {
echo "<script>alert('Session expired. Please try again.'); window.location.replace('index.php');</script>";
exit;
}
if ($otp != $otp_code) {
echo "<script>alert('Invalid OTP code');</script>";
} else {
try {
// Update user status to verified
$stmt = $pdo->prepare("UPDATE login SET status = 1 WHERE email = ?");
$stmt->execute([$email]);
echo "<script>
alert('Verification successful! You may sign in now.');
window.location.replace('index.php');
</script>";
} catch (PDOException $e) {
echo "<script>alert('Error: " . $e->getMessage() . "');</script>";
}
}
}
?>