-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_lab_work.php
More file actions
35 lines (27 loc) · 849 Bytes
/
delete_lab_work.php
File metadata and controls
35 lines (27 loc) · 849 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
session_start();
if (!isset($_SESSION['username'])) {
header("Location: index.php");
exit();
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['lab_work_id'])) {
$conn = mysqli_connect("localhost", "root", "", "lab_work_manager");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$username = $_SESSION['username'];
$user_table_name = "lab_works_" . strtolower($username);
$lab_work_id = $_POST['lab_work_id'];
$sql = "DELETE FROM `$user_table_name` WHERE id = ?";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, "i", $lab_work_id);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($conn);
header("Location: dashboard.php");
exit();
} else {
header("Location: dashboard.php");
exit();
}
?>