-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_confirm.php
More file actions
99 lines (82 loc) · 1.96 KB
/
delete_confirm.php
File metadata and controls
99 lines (82 loc) · 1.96 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
<?php
session_start();
include "dbcon.php";
if (!isset($_SESSION["user_id"])) {
header("Location: register.php");
exit;
}
$error = "";
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$otp = trim($_POST["otp"]);
$userID = $_SESSION["user_id"];
$stmt = $conn->prepare("SELECT delete_otp FROM users WHERE user_unique_id = ?");
$stmt->bind_param("s", $userID);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
if ($user && $otp === $user['delete_otp']) {
// Delete account
$del = $conn->prepare("DELETE FROM users WHERE user_unique_id = ?");
$del->bind_param("s", $userID);
$del->execute();
session_unset();
session_destroy();
header("Location: register.php?deleted=1");
exit;
} else {
$error = "Invalid OTP. Please try again.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Confirm Delete</title>
<style>
body {
background: #a8d9d6;
font-family: Arial;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box {
background: #74b5b4;
padding: 20px;
width: 300px;
text-align: center;
border-radius: 12px;
}
.input {
padding: 12px;
width: 90%;
border-radius: 10px;
border: none;
margin-bottom: 10px;
}
.btn {
background: #1e3b36;
color: white;
padding: 10px;
width: 80%;
border: none;
border-radius: 20px;
}
.error {
color: darkred;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="box">
<h3>Enter OTP to Delete Account</h3>
<?php if (!empty($error)) echo "<div class='error'>$error</div>"; ?>
<form method="POST">
<input type="text" name="otp" class="input" placeholder="Enter OTP" required>
<button class="btn" type="submit">Confirm Delete</button>
</form>
</div>
</body>
</html>