-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_account.php
39 lines (36 loc) · 1.44 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
<?php
require_once "dbConnection.inc";
session_start();
if (isset($conn) && $conn) {
if (isset($_POST["delete"])) {
$id = $_SESSION["user_id"];
$username = $_SESSION["user_username"];
$email = $_SESSION["user_email"];
$sql = "DELETE FROM freelance_info
WHERE freelance_id = '$id' AND freelance_username = '$username' AND freelance_email = '$email'";
$result = $conn->query($sql) or trigger_error("Connection Failed: " . $conn->error);
if ($conn->affected_rows === 1) {
echo "<script>alert('Account Deleted Successfully')
window.location.href='login.php?account_status=deleted_success';
</script>";
session_destroy();
} elseif ($conn->affected_rows > 1) {
echo "<script>alert('Too many accounts deleted')
window.location.href='login.php?account_status=too_many';
</script>";
session_destroy();
} else {
echo "<script>alert('Account Deletion Failed')
window.location.href='login.php?account_status=delete_failed';
</script>";
}
} else {
echo "<script>alert('Delete Button Not Selected')
window.location.href='settings.php?account_status=not_selected_btn';
</script>";
}
} else {
echo "<script>alert('Connection Failed..')
window.location.href='settings.php?account_status=conn_failed';
</script>";
}