Hi, I have a problem with a bit of code which checks to make sure that the date is in the correct format. Basically i need the user to be able to put 2008 as well as 2007 as some users will be putting 2008 now. At the moment it does not allow 2008 and only allows 2007. What would i need to change in the below? list($years, $months, $days) = array_map('intval', explode('-', $_POST['deliverydate'])); if ($years != date('Y') OR !checkdate($months, $days, $years)) { echo "Sorry you have entered the wrong date format for delivery date. The correct format is yyyy-mm-dd"; exit(); } Code (markup): Cheers, Adam
Your IF statement must be changed to: if ( ($years != date('Y') AND $years != date('Y') + 1) OR !checkdate($months, $days, $years)) PHP: This is the quickest solution for your code, the optimal one would require a bit more ample changes. Good luck!