-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompleteorder.php
69 lines (65 loc) · 1.83 KB
/
completeorder.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
67
68
69
<?php
include_once ('./config.php');
$con=mysqli_connect($servername,$username,$password,$dbname);
if (mysqli_connect_errno())
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
if(isset($_POST['cc']))
{
$cc=$_POST['cc'];
//echo $cc;
//echo 'done';
}
if(isset($_POST['sa']))
{
$sa=$_POST['sa'];
//echo $sa;
//echo 'done';
}
if(isset($_POST['ba']))
{
$ba=$_POST['ba'];
//echo $ba;
//echo 'done';
}
// echo $orderID;
if(isset($_COOKIE['UID']))
{
$userid= $_COOKIE['UID'];
//get ccid
$query="select ccID from team_best_rds.tbl_credit_card where userID=$userid";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_array($result);
$ccID = $row['ccID'];
//$today = date("Ymd");
//get orderid
$query="select * from team_best_rds.tbl_orders where ccID = $ccID and cart =1";
$result = $con->query($query);
$row = mysqli_fetch_array($result);
$orderID=$row['orderID'];
$query2 = "update tbl_orders SET cart = 0, ccID = $cc, shipping_addess=$sa,billing_addess=$ba where orderID = $orderID";
$result = $con->query($query2);
echo'<script>
alert("Your order has been placed!")
window.location.href = "index.php";
</script>
';
}
else{
echo'<script>
function myFunction() {
var r = confirm("Please Log In or Register to view cart!");
if (r == true) {
window.location.href = "login.php";
} else {
window.location.href = "index.php";
}
}
</script>
<script type="text/javascript">
myFunction();
</script>'
;
}
?>