-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
28 lines (20 loc) · 1.07 KB
/
checkout.php
File metadata and controls
28 lines (20 loc) · 1.07 KB
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "isdm";
$con = mysqli_connect($servername, $username, $password, $dbname);
session_start();
$uname = $_SESSION['user_name'];
$bid = $_REQUEST["q"];
$r10 = mysqli_query($con, "select CID from customer where CUserName = '$uname'") or die("q10 error!");
$cid = mysqli_fetch_row($r10);
$cid = $cid[0];
$r1 = mysqli_query($con, "insert into ordr(cid,purchasedate,paymentMode,orderstatus) values($cid,date(now()),'COD', 'pending')") or die("q1 err");
$ordrid = mysqli_insert_id($con);
$r2 = mysqli_query($con, "insert into orderedProduct(orderID, PId, quatity) select $ordrid, PId, quantity from basketProds where BID=$bid") or die("q2 err");
//$r5 = mysqli_query($con, "update product set pstock = pstock-quantity where PID =(Select pid ") or die("q2 err");
$r3 = mysqli_query($con, "update basket set numprods=0,totalcost=0 where bid=$bid") or die("q3 err");
$r4 = mysqli_query($con, "delete from basketprods where bid = $bid") or die("q4 err");
echo "Items bought successfuly. Thank You :)";
?>