-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook.php
35 lines (32 loc) · 823 Bytes
/
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
<?php
include('register.php');
$username="root";
$password="";
$dbname="carrent";
$conn=mysqli_connect("localhost",$username,$password,$dbname);
if (!$conn){
die("connect failed".mysql_error());
}
if(isset($_POST['book'])){
$user=$_SESSION['username'];
$from=$_POST['from'];
$to=$_POST['to'];
if (empty($from)) {
array_push($errors, "from date is required");
}
if (empty($to)) {
array_push($errors, "to date is required");
}
if(count($errors)==0){
$sql="SELECT * FROM register WHERE name='$user'";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_row($result);
$email=$row['email'];
$sql2="INSERT INTO booking(username,email,frmdate,todate) VALUES('$user','$email','$from','$to')";
$result2=mysqli_query($conn,$sql2);
}
else{
array_push($errors, "fill all the deatils");
}
}
?>