Hi all,
I have this PHP script (for a HTML form) which I would like to a) check if a checkbox is checked, and then b) if it is, to check some text fields for input. If the checkbox is not checked, these fields do not need to be checked.
This is my checkbox HTML:
<input id="want2book" type="checkbox" name="want2book" value="Yes" tabindex="11" />
..and this is the section of my PHP script which I can not get working (notice the commented out line above - this was an alternative attempt to get this to work):
//if($want2book == 'Yes'){
if($_POST['want2book'] == 'Yes')
{
if (empty($date) || empty($time)) {
header( "Location: $errorurl" );
exit ;
}
}
To summarise: If the checkbox 'want2book' is checked, I would like the script to make sure there is content in the two text fields 'date' and 'time' - if there is, great, submit and send out the email. If not, redirect the user to the $errorurl.
At present, the code above sends the email regardless of the check state and any input or not into the date and time fields. This is so simple but I just cant seem to grasp how to make it work...
Any help would be greatly appreciated