-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteitem.php
More file actions
43 lines (35 loc) · 996 Bytes
/
deleteitem.php
File metadata and controls
43 lines (35 loc) · 996 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
37
38
39
40
41
42
<?php
session_start();
$cartidToDelete = $_POST["cartid"];
$caridToDelete = $_POST["carid"];
deleteitem();
function deleteitem() {
global $cartidToDelete, $caridToDelete, $memberid;
// Create database connection.
$config = parse_ini_file('../../private/db-config.ini');
$conn = new mysqli($config['servername'], $config['username'], $config['password'], 'project1004');
// Check connection
if ($conn->connect_error)
{
$errorMsg = "Connection failed: " . $conn->connect_error;
$result = 0;
}
else
{
$stmt= $conn->prepare("DELETE FROM .cart WHERE id = ? ");
$stmt->bind_param("i", $cartidToDelete);
$stmt->execute();
if($stmt >= 1)
{
echo '<script>window.location.href = "cart.php";</script>';
}
else
{
echo "Prepare failed: (". $conn->errno.") ".$conn->error."<br>";
}
$stmt->close();
}
$conn->close();
return $result;
}
?>