-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
50 lines (44 loc) · 1.5 KB
/
checkout.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
<?php
session_start();
try{
$pri= $_GET["price"];
//$no_of_days=1;
//echo $pri;
$no_of_days= $_GET["days"];
//$car_id=$_GET["car_id"];
$price = $pri * $no_of_days;
$number_plate=$_GET["number_plate"];
$date_out = date("Y/m/d");
//$due_date= date('Y/m/d', strtotime($date_out. ' + '.$no_of_days.' days'));
$due_date=strftime("%Y/%m/%d", strtotime("$date_out +$no_of_days day"));
//$due_date=date("Y/m/d", $date);
$user_id=$_SESSION["user_id"];
$connection = mysqli_connect("localhost","root", "","car_rental") ;
mysqli_query($connection,"select * from cart where user_id= $user_id and date_in is null");
if(mysqli_affected_rows($connection)==0){
mysqli_query($connection,"insert into cart(user_id,
date_out,
due_date,
no_of_days,
number_plate,
AMOUNT_pay) values($user_id,'$date_out','$due_date',$no_of_days, '$number_plate', $price)");
/* mysqli_query($connection,"insert into cart(user_id,
date_out,
due_date,
no_of_days,
number_plate,
AMOUNT_pay) values('$user_id','$date_out','$due_date','$no_of_days', 'tx_123', 20)"); */
mysqli_query($connection, "update inventory set availability=0 where number_plate='$number_plate'");
echo "Your Car booked and Due date is: ".$due_date;
echo '<p><b><a href= "userpagemain.php?"><-Back</a></b></p>';
// echo '<button><a class="page-scroll" href="http://localhost:8888/logout.php">Log Out</a></button>';
}
else
echo "Sorry, only one car can be booked at a time";
}
catch(PDOException $e)
{
echo "<br>" . $e->getMessage();
}
mysqli_close ($connection);
?>