-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorderphp.php
36 lines (27 loc) · 1.04 KB
/
orderphp.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
<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ait";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$name = $_POST['firstName'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$pizza = $_POST['pizza'];
$quantity = $_POST['quantity'];
$toppings = $_POST['toppings'];
$size= $_POST['size'];
settype($quantity, "integer");
$sql1= "select price from pizzas where name='$pizza'";
$result = mysqli_query($conn, $sql1) or die("database error:". mysqli_error($conn));
$row = mysqli_fetch_array($result);
$base_pay = $row[0];
$sql = "INSERT INTO `order` (`name`, `address`, `phone`, `pizza`, `quantity`,`toppings`,`size`) VALUES ('$name', '$address', '$phone','$pizza','$quantity','$toppings','$size')";
mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn)."qqq".$sql);
echo $base_pay*$quantity;
?>