-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_account.php
41 lines (38 loc) · 1.18 KB
/
delete_account.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
if(!isset($_COOKIE['userid']) && isset($_COOKIE['password'])){
echo "<script>alert('You Need To Login To Access This Page !'); window.location.href = 'index.php';</script>";
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
if (!isset($_COOKIE["userid"])) {
echo "failure";
}
else {
$conn = mysqli_connect("localhost", "root", "", "book_store");
if ($conn) {
$userid = $_COOKIE["userid"];
$deletesql = "DELETE FROM users WHERE userid = '$userid' OR email = '$userid';";
$result = mysqli_query($conn, $deletesql);
if ($result) {
setcookie("userid", "", time() - 3600);
setcookie("password", "", time() - 3600);
echo "success";
} else {
echo "failure";
}
} else {
echo "database_error";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="IMAGES/delete-account.png"/>
<title>Delete Account</title>
</head>
<body>
</body>
</html>