/
process-book.php
49 lines (39 loc) · 1.27 KB
/
process-book.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
<?php
require('inc\connect.php');
session_start();
$email = $_SESSION["email"];
$model = $_SESSION["model"];
$vehicle = $_SESSION["vehicle"];
$status="RESERVED";
$plateno = $_SESSION["plateno"];
$plot = $_SESSION["plot"];
$account = $_SESSION["account"];
$street = $_SESSION["street"];
$from = $_SESSION["from"];
$to = $_SESSION["to"];
$charge = "120";
$phone = $_SESSION["phone"];
/*CHECK IF RESERVED */
$conn = mysqli_connect("localhost", "root", "", "cpms");
$sql="SELECT * FROM zones WHERE street='$street' and plot='$plot' and status='RESERVED'";
$result=mysqli_query($conn, $sql);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If
if($count==1){
header('location:error-book.php');
}
else
{
$query = "INSERT INTO `zones` (phone,status, email, model, vehicle,street,plot,platenumber,account,charge,d1,d2) VALUES ('$phone','$status', '$email', '$model', '$vehicle' , '$street', '$plot', '$plateno', '$account','$charge','$from','$to')";
$result = mysqli_query($conn, $query);
$var = $_SESSION["from"];
$date = str_replace('/', '.', $var);
echo date('Y.m.d', strtotime($date));
if($result){
//REDIRECT
header('location:success.php');
exit;
}
}
?>