-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
35 lines (30 loc) · 986 Bytes
/
delete.php
File metadata and controls
35 lines (30 loc) · 986 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
31
32
33
34
35
<?php
$mysqli = new mysqli("localhost","foobarcs411_gwehner2","password123","foobarcs411_scheduler");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
session_start();
$myusername = $_SESSION['username'];
//$email = $_GET["Email"];
$email = $myusername;
if($email==$myusername)
{
$query = "SELECT COUNT(*) AS count FROM User WHERE Email = '$email'";
$result= $mysqli->query($query);
$num = $result->fetch_assoc()['count'];
if($num != 0)
{
echo 'Found and deleted '.$num.' record with email id: '.$email;
$result->free();
$query = "DELETE FROM User WHERE Email = '$email'";
$result= $mysqli->query($query);
}
else
{echo 'Could not find a record with email id: '.$email;}
}
else
{
echo "You can not delete any other user's account! The email ".$email. " and the username ".$myusername. " do not match!";
}
$mysqli->close();
?>