I need your help. I’m stuck at a point from where I can’t figure it out that how to stop a product to be booked twice a day on a web form.
I have 41 products to rent out on daily basis.
My problem is: if a client books a product #4 (pg_no) and date 26-06-2017 then another client isn't able to book the same product for the same period of time.
If a client selects the same product and date, then a message should appear saying "already booked - please select another date"
Also, do I have to define anything on database level?
Your help will be highly appreciated.
Please note: this rule is only for product # (pg_no) and date fields are not allow for the same day.
<?php
//connecting string
include("dbconnect.php");
//assigning
$pg_no=$_REQUEST['pg_no'];
$name=$_REQUEST['Name'];
$tele=$_REQUEST['Tele'];
$city=$_REQUEST['City'];
$date=$_REQUEST['Date'];
//checking if pg_no and Date are same
$check=mysqli_query($db_connect,"SELECT * FROM lstclient WHERE pg_no='{$pg_no}', Date='{$date}'");
if(mysqli_fetch_row($check) ==0)
{
echo "Already booked please select another date<br/>";
}
//if not the insert data
else
{
$query=mysqli_query($db_connect,"INSERT INTO lstclient(pg_no,Name,Tele,City,Date) VALUES('$pg_no','$name','$tele','$city','$date')") or die(mysql_error());
}
mysqli_close($db_connect);
// messaging
if($query)
{
header("location:index.php?note=failed");
}
else
{
header("location:index.php?note=success");
}
?>