-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_project.php
More file actions
executable file
·44 lines (35 loc) · 1.1 KB
/
delete_project.php
File metadata and controls
executable file
·44 lines (35 loc) · 1.1 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
39
40
41
42
43
44
<?php
$conn = require __DIR__ . "/database.php";
session_start();
if (!isset($_SESSION["email"])) {
// Redirect to the login page if the user is not logged in
header('Location: index.php');
exit();
}
$email = mysqli_real_escape_string($conn, $_SESSION['email']);
$query = "SELECT * FROM account WHERE email='$email'";
$result = mysqli_query($conn, $query);
if ($row = mysqli_fetch_assoc($result)) {
$name = $row['userName'];
$password = $row['password'];
$phone = $row['phoneNum'];
$role = $row['role'];
} else {
// Handle case where email is not found in the database
$name = '';
$password = '';
$phone = '';
$role = '';
}
if (isset($_POST['project_id'])) {
$project_id = $_POST['project_id'];
// Execute a DELETE query to remove the project from the database
$delete_query = "DELETE FROM project WHERE id = $project_id";
if (mysqli_query($conn, $delete_query)) {
// Project deleted successfully
echo "success";
} else {
// Error occurred while deleting the project
echo "Error: " . mysqli_error($conn);
}
}