I want to display this message "Already booked - please select another date" If two clients select the same product (pg_no)and date (Date). UNIQUE CONSTRAINT
<?php
//connecting string
include("dbconnect.php");
//assigning
$name=$_REQUEST['Name'];
$tele=$_REQUEST['Tele'];
$city=$_REQUEST['City'];
// UNIQUE CONSTRAINT
$pg_no=$_REQUEST['pg_no']; //product
$date=$_REQUEST['Date']; //date
//checking if pg_no and Date are same
$check = mysqli_query($db_connect,"SELECT * FROM lstclient WHERE pg_no='{$pg_no}', Date='{$date}'");
{
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());
}
// link closing
mysqli_close($db_connect);
// messaging
if($query)
{
header("location:index.php?note=failed");
}
else
{
header("location:index.php?note=success");
}
?>