-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete_account.php
38 lines (33 loc) · 1.01 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
<?php
ob_start();
session_start();
include("./connect_to_db.php");
include_once("./library.php");
$db = DbUtil::loginConnection();
$con = new mysqli($SERVER, $USERNAME, $PASSWORD, $DATABASE);
//check if db connects
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Changing password
$confirm= $_POST["decision"];
$name = $_SESSION["username"];
if($confirm == "Yes"){
$sql = "DELETE FROM Users WHERE username='$name'";
$query = $db->query($sql);
if ($query == TRUE) { ?>
<script type = "text/javascript">
document.cookie = "loginwrong=right";
window.location.replace("index.html");
</script> <?php
}
} else {
?>
<script type = "text/javascript">
document.cookie = "loginwrong=wrong";
window.location.replace("edit_profile.html");
</script>
<?php
}
$db->close();
?>