-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveuser.php
More file actions
38 lines (38 loc) · 1.53 KB
/
Copy pathremoveuser.php
File metadata and controls
38 lines (38 loc) · 1.53 KB
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
session_start();
$username = $_POST["username"];
$password = $_POST["password"];
$connection = new mysqli("localhost", "root", "", "choretastic");
if($connection->connect_error){
die("Connection failed: " . $connection->connect_error);
}
if($_SESSION["username"] == $username && $_SESSION["password"] == $password){
$query = "SELECT id, username FROM admin_table WHERE username='".$_SESSION["username"]."'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
$sql = "DROP TABLE `".strval($row["id"])."`";
if($connection->query($sql) === true){
echo "Connection successful";
}else{
echo "Connection failed" . $connection->error;
}
$sql = "DELETE FROM admin_table WHERE id='".$row["id"]."'";
if($connection->query($sql) === true){
echo "Connection successful";
}else{
echo "Connection failed" . $connection->error;
}
header("Location: login.php");
}else{
$query = "SELECT id, username FROM admin_table WHERE username='".$username."'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
$sql = "DELETE FROM admin_table WHERE username='".$username."'";
if($connection->query($sql) === true){
echo "Connection successful";
}else{
echo "Connection failed" . $connection->error;
}
}
header("Location: home.php");
?>