This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
delete-account.php
58 lines (53 loc) · 1.64 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once "pdo.php";
require_once "head.php";
date_default_timezone_set('Asia/Taipei');
if (!isset($_SESSION["email"])) {
echo "<p class='die-msg'>PLEASE LOGIN</p>";
echo '<link rel="stylesheet" href="./style.css?v=<?php echo time(); ?>">';
echo "<br />";
echo "<p class='die-msg'>Redirecting in 3 seconds</p>";
header("refresh:3;url=index.php");
die();
}
if ($_SESSION['email'] == 'guest@guest.com') {
echo "<p class='die-msg'>LOGGED IN AS GUEST ACCOUNT</p>";
echo "<p class='die-msg'>EDIT ACCOUNT DETAILS NOT ALLOWED</p>";
echo '<link rel="stylesheet" href="./style.css?v=<?php echo time(); ?>">';
echo "<br />";
echo "<p class='die-msg'>Redirecting in 3 seconds</p>";
header("refresh:3;url=index.php");
die();
}
if (isset($_POST['delete'])) {
$sql = "DELETE FROM account WHERE user_id = :uid";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(':uid' => $_SESSION['user_id']));
$_SESSION['success'] = 'Account deleted';
session_destroy();
header('Location: ./login.php');
return;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Delete Account</title>
<style>
form {
width: 100%;
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
</style>
</head>
<body>
<form class="form-signin" action="delete-account.php" method="post" enctype="multipart/form-data">
<h1 class="h3 mb-3 font-weight-normal">Delete Account</h1>
<input class="btn btn-lg btn-primary btn-block" type="submit" value="Delete Account" name="delete">
<br />
<a href="./index.php">Cancel</a>
</form>
</body>
</html>