zed420 Posted August 9, 2009 Share Posted August 9, 2009 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/ Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 try this instead <?php $day = $_GET['day']; $cMonth = $_GET['cMonth']; $cYear = $_GET['cYear']; $today = time(); $date = mktime(0,0,0,$cMonth,$day+1,$cYear)-1; //add 1 day subtract 1 second if($today > $date) { echo "error"; // post date } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894292 Share on other sites More sharing options...
zed420 Posted August 9, 2009 Author Share Posted August 9, 2009 Thank you MadTechie for your reply just one thing, I know it should give error on post date but its giving it on Todays date too. any thoughts??? Rest is fine Zed Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894310 Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 ahh okay just change $day+1 to $day Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894313 Share on other sites More sharing options...
zed420 Posted August 9, 2009 Author Share Posted August 9, 2009 Sorry to bother you again this is what I'm getting if take off +1 Warning: mktime() expects parameter 5 to be long, string given in C:\xampp\htdocs\calendar\test.php on line 16 error Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894318 Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 See updated line <?php $day = $_GET['day']; $cMonth = $_GET['cMonth']; $cYear = $_GET['cYear']; $today = time(); $date = mktime(0,0,0,$cMonth,$day,$cYear)-1; //updated if($today > $date) { echo "error"; // post date } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894356 Share on other sites More sharing options...
zed420 Posted August 9, 2009 Author Share Posted August 9, 2009 Sorry madTechie same error mgs as before Warning: mktime() expects parameter 5 to be long, string given in C:\xampp\htdocs\calendar\test.php on line 16 error Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894359 Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 considering the code I posted has 6 parameter I'll have to assume you did something wrong, can you post what you have, also do you want the error if its the same day ? as my first code doesn't return an error on the same day but the 2nd code will! Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894365 Share on other sites More sharing options...
zed420 Posted August 9, 2009 Author Share Posted August 9, 2009 Here you go, this one doesn't let you book for today but I DON'T want the error if its same day. I want it so the people can book it for the same day. thanks for all this Zed $day = $_GET['day']; $cMonth = $_GET['cMonth']; $cYear = $_GET['cYear']; $today = time(); $request_date = mktime(0,0,0,$cMonth,$day+1,$cYear)-1; //add 1 day subtract 1 second if($today > $request_date) { echo "Error, Post date"; // post date }else{ echo 'You are about to book a lesson for <div class="everyday">'.date('j F Y', $request_date ).'</div>'; } Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894389 Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 Works okay here, try this (forcing the values to today) <?php date_default_timezone_set('GMT'); $day = $_GET['day']; $cMonth = $_GET['cMonth']; $cYear = $_GET['cYear']; //Debug $day = 10; $cMonth = 8; $cYear = 2009; //End debug $today = time(); $request_date = mktime(0,0,0,$cMonth,$day+1,$cYear)-1; //add 1 day subtract 1 second if($today > $request_date) { echo "Error, Post date"; // post date }else{ echo 'You are about to book a lesson for <div class="everyday">'.date('j F Y', $request_date ).'</div>'; } Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894394 Share on other sites More sharing options...
zed420 Posted August 9, 2009 Author Share Posted August 9, 2009 MadTechie you've been wonderful thank you very much for all your help Zed Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894400 Share on other sites More sharing options...
MadTechie Posted August 9, 2009 Share Posted August 9, 2009 Ahh before you make this as solved, I assume you found a bug and fixed it, as the debug code is ONLY for testing.. if it works you need to get the $_GET values Quote Link to comment https://forums.phpfreaks.com/topic/169490-solved-booking-on-calendar/#findComment-894402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.