Date and Time PHP/HTML
Posted: Wed May 04, 2011 3:17 am
Hi all,
I've been working on my website to create a booking page. The only thing i've got left is the validation for the time and date. They are drop down boxes.
The time consists of only 1 drop down box and the date consists of 3 drop down's (day-month-year).
My problem is that I know in plain English what the box needs to do but cause of a lack of skill I cant figure out how to code the validation for it. (and yes I have searched all google for this and I know that there are some validations but not the ones that can help me with the way I implemented my drop down boxes)
For the time I want to validate that the user cannot choose a time which has already been booked on the same date as someone else.
For the date I want to validate that the user cannot choose a date which is less or equal to the current date.
I'm still in my learning progress so any help is appreciated. I can show the validation which I have already made for the booking so you lot know what level of coding is..
And this is the booking layout to make it easier to understand:

Thanks
I've been working on my website to create a booking page. The only thing i've got left is the validation for the time and date. They are drop down boxes.
The time consists of only 1 drop down box and the date consists of 3 drop down's (day-month-year).
My problem is that I know in plain English what the box needs to do but cause of a lack of skill I cant figure out how to code the validation for it. (and yes I have searched all google for this and I know that there are some validations but not the ones that can help me with the way I implemented my drop down boxes)
For the time I want to validate that the user cannot choose a time which has already been booked on the same date as someone else.
For the date I want to validate that the user cannot choose a date which is less or equal to the current date.
I'm still in my learning progress so any help is appreciated. I can show the validation which I have already made for the booking so you lot know what level of coding is..
Code: Select all
require_once("connect.php");
if (empty($_POST["gp"]) && (empty($_POST["nurse"])))
{
echo("Error! Please select a nurse or a doctor <br /><br />
<a href='booking.php'><b>Please try again</b></a>.");
}
else if (!empty($_POST["gp"]) && (!empty($_POST["nurse"])))
{
echo("Error! Please select ONLY a nurse or a doctor <br /><br />
<a href='booking.php'><b>Please try again</b></a>.");
}
else if (empty($_POST['username']))
{
echo("Please enter your username<br /><br />
<a href='booking.php'><b>Please try again</b></a>.");
}
else if (($_POST['username']) != ($_SESSION['username']))
{
echo ("Error! This username does not exist.<br /><br />
<a href='booking.php'><b>Please try again</b></a>.");
}
else{
// Book the appointment.
$query = mysql_query("INSERT INTO appointment
(appointmentID, username, day, month, year, time, gp, nurse)
VALUES ('NULL', '".$_POST['username']."', '".$_POST['day']."', '".$_POST['month']."','".$_POST['year']."', '".$_POST['time']."', '".$_POST['gp']."', '".$_POST['nurse']."')")
or die (mysql_error());
echo "You have successfully booked an appointment!<br /><br />
To go back to the home page click <a href='indexmembers.php'><b>here</b></a>.";
}
Thanks