-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddToCart.php
More file actions
39 lines (31 loc) · 920 Bytes
/
Copy pathAddToCart.php
File metadata and controls
39 lines (31 loc) · 920 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
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$databasename = "database name";
$conn = mysqli_connect('localhost', 'root', '', 'final');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$Item = "";
$Descrip = "";
$Price = "";
if (isset($_POST['save'])) {
$Item = $_POST['Item'];
$Descrip = $_POST['Descrip'];
$Price = $_POST['Price'];
$sql = "INSERT INTO cart (Item, Descrip, Price)
VALUES ('$Item', '$Descrip', '$Price')";
$sql2 = "INSERT INTO all_sales (Item, Descrip, Price)
VALUES ('$Item', '$Descrip', '$Price')";
$result = mysqli_query($conn, $sql);
$result = mysqli_query($conn, $sql2);
if (!$result) {
die('Error: ' . mysqli_error($conn));
}
// Redirect to menu.php after successful form submission
header('Location: menu.php');
exit();
}
?>