-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpurchase.php
54 lines (46 loc) · 1.21 KB
/
purchase.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
<?php
session_start();
include("db_conn.php");
if($_SERVER['REQUEST_METHOD']=="POST")
{
if(isset($_POST['pay']))
{
$ono=1020;
$a="select ono from ord";
$ab=pg_query($conn,$a);
$r=pg_num_rows($ab);
$ono=$ono+$r;
// while($r <> NULL){
// $ono=$ono+1 ;
// $a="select ono from ord";
// $ab=pg_query($conn,$a);
// $r=pg_fetch_array($ab,$row=null);
// }
$odate=date('d.m.y');
$mob=$_SESSION['mobno'];
if(isset($_POST['address'])){
$add=$_POST['address'];
}
$order="insert into ord(ono,odate,mobno,address,tcost) values($ono,'$odate',$mob,'$add',0)";
if(pg_query($conn,$order)){
foreach($_SESSION['cart'] as $key => $value)
{
$pid=$value['pid'];
$qty=$value['Quantity'];
$a="select rate from product where pid=$pid";
$ab=pg_query($conn,$a);
$product=pg_fetch_array($ab);
$rate=$product['rate'];
$q="insert into orddetails(ono,pid,qty,rate) values($ono,$pid,$qty,$rate)";
$s=pg_query($conn,$q);
}
}
echo "<script>
alert('Successfully Order is Placed');
window.location.href='face.php';
</script>";
session_unset();
session_destroy();
}
}
?>