forked from Harsh21Patel/Inventory-Management-System-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
24 lines (22 loc) · 673 Bytes
/
Copy pathdelete.php
File metadata and controls
24 lines (22 loc) · 673 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
<?php
session_start();
if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) {
header("Location: index.html");
exit();
}
mysqli_report(MYSQLI_REPORT_OFF);
$db = mysqli_connect('localhost', 'root', '', 'inventorymanagement');
if (mysqli_connect_errno()) {
die("Connection failed. Please try again later.");
}
?>
<?php
if (isset($_GET['id']) && is_numeric($_GET['id']) && (int)$_GET['id'] > 0) {
$id = (int)$_GET['id'];
$stmt = mysqli_prepare($db, "DELETE FROM product WHERE product_id = ?");
mysqli_stmt_bind_param($stmt, "i", $id);
mysqli_stmt_execute($stmt);
}
header("Location: table.php");
exit();
?>