-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdel.php
More file actions
36 lines (36 loc) · 983 Bytes
/
del.php
File metadata and controls
36 lines (36 loc) · 983 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
36
<?php
$con = mysqli_connect("us-cdbr-iron-east-04.cleardb.net","b966a2a16a969f","01d02abd","heroku_0b7502a16e114a3");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
elseif(isset($_POST["sub"]))
{
$oid = mysqli_escape_string($con,$_POST["oid"]);
$sel = "SELECT productID,quantity FROM orders WHERE orderID = '$oid'";
$result = mysqli_query($con,$sel);
if(!$result)
{
die('Error: ' . mysqli_error($con));
}
else
{
$row = mysqli_fetch_array($result);
$quantity = $row["quantity"];
$pid = $row["productID"];
$sql = "DELETE FROM orders WHERE orderID = '$oid'";
$sql2 = "UPDATE product SET stock = stock + '$quantity' WHERE productID = '$pid'";
$res = mysqli_query($con,$sql);
$res2 = mysqli_query($con,$sql2);
if(!$res || !$res2)
{
die('Error: ' . mysqli_error($con));
}
else
{
echo "<script> window.location.href = 'viewOrder.php';</script>";
}
}
}
mysqli_close($con);
?>