Forum Moderators: coopster

Message Too Old, No Replies

Booking on Calendar

         

zed420

7:45 pm on Aug 9, 2009 (gmt 0)

10+ Year Member



Hi All
Can someone please help me with this code all I'm trying to do is book driving lessons online via Calendar. So if someone hits on passed date,month or year he/she gets message 'The date has passed' else they can book their lesson on clicked day. There are NO errors on script but it not working right.
thanks
Zed
<?php
$day = $_GET['day'];
$cMonth = $_GET['cMonth'];
$cYear = $_GET['cYear'];
$today = date("j");
$month = date("n");
$year = date("y");

if (($day < $today)&&($cMonth <= $month)){
echo "<p>This date has Passed, Please choose another</p>";
}elseif (($cMonth < $month)&&($cYear <= $year)){
echo "<p>This date has Passed, Please choose another</p>";
}elseif (($cMonth >= $month)&&($cYear >= $year)){
echo "You are about to book a lesson for <div class=\"everyday\">$day $cMonth $cYear</div>";
}else{
echo "You are about to book a lesson for <div class=\"everyday\">$day $cMonth $cYear</div>";
}
?>

whoisgregg

9:49 pm on Aug 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi zed420,

I'd recommend converting the dates to time stamps and comparing those directly. Something along these lines:

$request_date = mktime( 0,0,0, $_GET['cMonth'], $_GET['day'], $_GET['cYear']); 
$today = mktime(0,0,0, date('j'), date('n'), date('Y'));
if($request_date <= $today){
echo '<p>This date has Passed, Please choose another</p>';
} else{
echo 'You are about to book a lesson for <div class="everyday">'.date('j n y', $request_date ).'</div>';
}