-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocess_cart.php
More file actions
35 lines (23 loc) · 928 Bytes
/
Copy pathprocess_cart.php
File metadata and controls
35 lines (23 loc) · 928 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
<?php session_start();
// Create database connection
$db = mysqli_connect("localhost", "root", "", "food");
// Initialize message variable
$msg = "";
if (isset($_POST['submit'])) {
$qty = mysqli_real_escape_string($db, $_POST['qty']);
$chef = mysqli_real_escape_string($db, $_POST['chef']);
$name = mysqli_real_escape_string($db, $_POST['name']);
$category = mysqli_real_escape_string($db, $_POST['category']);
$rate = mysqli_real_escape_string($db, $_POST['rate']);
$unid = $_SESSION['id'];
$sql = "INSERT INTO cart (id,quantity,chef,name,category,rate) VALUES ('$unid', '$qty', '$chef', '$name', '$category', '$rate')";
mysqli_query($db, $sql);
header("Location: menu.php");
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
mysqli_query($db, "DELETE FROM cart WHERE s_no=$id");
$_SESSION['message'] = "Address deleted!";
header('location: menu.php');
}
?>