-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturnbackend.php
62 lines (45 loc) · 1.6 KB
/
returnbackend.php
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
<?php
session_start();
$rcid = $_SESSION['rcid'];
$cpid = $_SESSION['cpid'];
// echo $rcid;
// echo '<br>';
// echo $cpid;
$conn = mysqli_connect("sql1.njit.edu", "mp973", "Laptop2001.", "mp973");
//$result = mysqli_query($conn, "SELECT * FROM CostumerRecord;");
$result = mysqli_query($conn, "SELECT * FROM CostumerPurchases");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$count = mysqli_num_rows($result);
$x = 0;
function redirect($url) {
header('Location: '.$url);
die();
}
while($row = mysqli_fetch_assoc($result)){
if($row['PCostumerID']== $rcid && $row['PurchaseID']==$cpid){
$sql = "DELETE FROM `CostumerPurchases` WHERE PurchaseID = $cpid;";
break;
}else{
$x += 1;
continue;
}
}
if($x == $count){
echo '<script type="text/javascript">';
echo ' alert("PURCHASE ID DOES NOT EXIST FOR THE COSTUMER. PLEASE CHECK AND RE-ENTER PURCHASE ID.")'; //not showing an alert box.
echo '</script>';
header('refresh:0.1; url= returnorder.php');
//redirect('returnorder.php');
}
//echo "Costumer not found.";
if ($conn->query($sql) === TRUE) {
echo '<script type="text/javascript">';
echo ' alert("Costumer Purchase Returned.")'; //not showing an alert box.
echo '</script>';
header('refresh:0.1; url= returnorder.php');
} else {
echo "Error deleting record: " . $conn->error;
}
?>