-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteinv.php
More file actions
94 lines (64 loc) · 2.11 KB
/
Copy pathdeleteinv.php
File metadata and controls
94 lines (64 loc) · 2.11 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
include "includes/base.php";
?>
<html>
<head>
<title>Delete</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<?php include("includes/header.php");?>
<?php include("includes/nav.php");?>
<div id='section'>
<?php
if($_POST['deletetable']!=''){
$table = htmlspecialchars($_POST['deletetable']);
}
if($_POST['deleteid']!=''){
$id = htmlspecialchars($_POST['deleteid']);
}
//ALTER TABLE city DROP FOREIGN KEY `city_ibfk_1`;
//ALTER TABLE city ADD CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`) ON DELETE CASCADE;
//ALTER TABLE countrylanguage DROP FOREIGN KEY `countryLanguage_ibfk_1`;
//ALTER TABLE countrylanguage ADD CONSTRAINT `countryLanguage_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`) ON DELETE CASCADE;
if($table == "ingredient"){
$sql = "DELETE FROM " . $table . " WHERE name = ?";
if($stmt = mysqli_prepare($link, $sql)){
mysqli_stmt_bind_param($stmt,'s',$id);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$_SESSION['success'] = "Success: Ingredient - " . $id . " - successfully deleted.";
header("location:inventory.php");
exit();
}
else {
$_SESSION['error'] = "Error: Ingredient - " . $id . " - not successfully deleted.";
header("location:inventory.php");
exit();
}
}
else if($table == "keg"){
$sql = "DELETE FROM " . $table . " WHERE keg_id = ?";
if($stmt = mysqli_prepare($link, $sql)){
mysqli_stmt_bind_param($stmt,'s',$id);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$_SESSION['success'] = "Success: Keg - " . $id . " - successfully deleted.";
header("location:inventory.php");
exit();
}
else {
$_SESSION['error'] = "Error: Keg - " . $id . " - not successfully deleted.";
header("location:inventory.php");
exit();
}
}
//echo '<meta http-equiv="refresh" content="1; URL=failure.php" />';
?>
</div>
<?php include("includes/footer.php");?>
</body>
</html>
<?php
mysqli_close($link);
?>