-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete.php
57 lines (44 loc) · 1.25 KB
/
delete.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
if (isset($_GET['userid']))
{
session_start();
//collection form data
$userid = $_GET['userid'];
// database connection parameters
// $servername = "localhost";
// $username = "root";
// $db_password = "creativeS@23";
// $dbname = "creative_db";
$servername = "localhost";
$username = "root";
$db_password = "";
$dbname = "creative_db";
// Create connection
$conn = new mysqli($servername, $username, $db_password, $dbname);
// Check connection
if ($conn->connect_error) {
//stop executing the code and echo error
echo ("Connection failed: " . $conn->connect_error);
header("Location: adminverification.php");
exit();
}
$sql = "DELETE FROM users WHERE userID = '$userid'";
$result = $conn->query($sql);
if ($result === TRUE) {
$_SESSION['done'] = "successfully deleted";
header("Location: adminverification.php");
exit();
} else {
$_SESSION['wrong'] = "Encountered an error";
header("Location: adminverification.php");
exit();
}
//close database connection
$conn->close();
}
else {
// redirect to login page
header("Location: adminverification.php");
exit();
}
?>