On Mon, 2010-06-07 at 16:51 -0400, David Mehler wrote: > Hello, > I've got a form with three fields that are not required for proper > completion of it, ending month, day, year fields. If a user enters > nothing no problem, but if those form fields are entered I need them > validated. They have to be in the correct format YYYY-MM-DD date > format and that value also has to be greater than the starting date > validated previously. I've got some not working code. > Thanks. > Dave. > > // if an ending date field was entered validate that > // also must be greater than the starting date values > if(!empty($_POST['month1']) && !empty($_POST['day1']) && > !empty($_POST['year1']) { > $month1=$_POST['month1']; > $day1=$_POST['day1']; > $year1=$_POST['year1']; > $date_value1="$year1-$month1-$day1"; > } > if(!checkdate($month1,$day1,$year1)) { > echo "Invalid Date.\n"; > } else { > echo "Entered Date is correct.\n"; > } > } > if(!checkdate($month1,$day1,$year1)) > $date_value { > echo "Invalid Date.\n"; > } else { > echo "Entered Date is correct.\n"; > } > strtotime() can create a timestamp from a date string that you can use to compare two dates, and the strings can be put together with the values from the variables. I'm assuming that your form is using a combination of select lists to create the date, so you should be able to just grab the integer values to test they are within valid ranges for a date. Thanks, Ash http://www.ashleysheridan.co.uk