-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkoutdown.php
66 lines (55 loc) · 1.71 KB
/
checkoutdown.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
63
64
65
66
<?php
session_start();
if(!isset($_SESSION['name']))
{
session_destroy();
echo "<script type='text/javascript'>
window.location.href='login.php'</script>";
}
if(!isset($_POST['purchaseId']) && !isset($_POST['address']) && !isset($_POST['pin_code']) && !isset($_POST['mobile_number']) && !isset($_POST['cake_message']))
{
echo "<script type='text/javascript'>
window.location.href='cart.php'</script>";
}
$purchaseId = $_POST['purchaseId'];
$address = $_POST['address'];
$pinCode = $_POST['pin_code'];
$mobileNumber = $_POST['mobile_number'];
$cakeMessage = $_POST['cake_message'];
$userId = $_SESSION['id'];
$name = $_SESSION['name'];
$dt = new DateTime();
$time = $dt->format('Y-m-d H:i:s');
include_once 'includes/db_config.php';
$db = new Database();
$conn = $db->getConnection();
$query = "INSERT INTO orders values('$purchaseId', '$userId', '$time', '$name', '$address', '$pinCode', '$mobileNumber', '$cakeMessage', ' ')";
$q = $conn->query($query);
if($q)
{
$query = "DELETE from orderd_item where purchase_id = '$purchaseId'";
$q = $conn->query($query);
if($q)
{
echo '<script language="javascript">';
echo 'alert("Ordered place successfull")';
echo '</script>';
echo "<script type='text/javascript'>
window.location.href='cart.php'</script>";
}
else
{
echo '<script language="javascript">';
echo 'alert("Something went wrong")';
echo '</script>';
echo "<script type='text/javascript'>
window.location.href='cart.php'</script>";
}
}
else{
echo '<script language="javascript">';
echo 'alert("Something went wrong")';
echo '</script>';
echo "<script type='text/javascript'>
window.location.href='cart.php'</script>";
}