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']) Quote 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. Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/237401-form-validation/#findComment-1220089 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.