forked from aorti017/CS180-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteAccount.php
More file actions
30 lines (25 loc) · 933 Bytes
/
Copy pathdeleteAccount.php
File metadata and controls
30 lines (25 loc) · 933 Bytes
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
<?php
include "./database.php";
session_start();
$userVar = "";
if (isset($_COOKIE['username'])) {
$userVar = $_COOKIE['username'];
}
else {
header('Location: index.php');
}
$sql = "DELETE FROM Users WHERE username='".$userVar."'"; //following lines extracts all of current users info
executeStatement($sql);
$sql = "DELETE FROM Messages WHERE sender='".$userVar."' OR receiver='".$userVar."'";
executeStatement($sql);
$sql = "DELETE FROM Contacts WHERE username='".$userVar."' OR contact='".$userVar."'";
executeStatement($sql);
$sql = "DELETE FROM Blocked WHERE username='".$userVar."' OR blocked='".$userVar."'";
executeStatement($sql);
// deletes the cookies for the logged in user when the user presses 'logout'
setcookie('username', '', time()-3600);
// deletes the user session
session_unset();
session_destroy();
header('Location: index.php');
?>