sofia403 Posted May 25, 2011 Share Posted May 25, 2011 hi, i want to check in a form if a date submitted is not null, how can i modify this script if( empty($_POST['year'] . '-' . $_POST['month'] . '-' .$_POST['day']) Link to comment https://forums.phpfreaks.com/topic/237401-form-validation/ Share on other sites More sharing options...
QuickOldCar Posted May 25, 2011 Share Posted May 25, 2011 Something like this as an example: if(empty($_POST['year']) || empty($_POST['month']) || empty($_POST['day'])) { // one or all is empty do something here like redirect back so user can insert values $date_ok = false; } else { // all have values continue with code $date_ok = true; } or can even do more checks on it and the other way, must be set and not empty for each if(isset($_POST['year']) && !empty($_POST['year']) && isset($_POST['month']) && !empty($_POST['month']) && isset($_POST['day']) && !empty($_POST['day'])) { //continue with code only if all above conditions are met } whichever way you do it you must check all 3 values separate, not as one empty plus other code just used for displaying purposes. Or in this case you manually assembling your date. Link to comment https://forums.phpfreaks.com/topic/237401-form-validation/#findComment-1219893 Share on other sites More sharing options...
sofia403 Posted May 25, 2011 Author Share Posted May 25, 2011 thanks for reply QuickOldCar i got it figured now, but thanks anyways! Link to comment https://forums.phpfreaks.com/topic/237401-form-validation/#findComment-1220089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.