rc51boss Posted April 15, 2011 Share Posted April 15, 2011 I've created a form to collect user information and send it to an email address. The form is setup not to accept any blank fields. I dont want the form to submit if the state field contains 'GA'. What would that code look like. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/ Share on other sites More sharing options...
Skewled Posted April 15, 2011 Share Posted April 15, 2011 psuedo: if ($_POST['state'] == 'GA') { exit(); // Or post error to let the user know then exit } else { Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/#findComment-1201892 Share on other sites More sharing options...
rc51boss Posted April 15, 2011 Author Share Posted April 15, 2011 Thanks, is 'GA' case sensitive? I already have code for a blank field, will they conflict? Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/#findComment-1201893 Share on other sites More sharing options...
Muddy_Funster Posted April 15, 2011 Share Posted April 15, 2011 a bit of cut and paste using kadeous's original code: if (($_POST['state'] == 'GA') || ($_POST['state'] == 'ga') || ($_POST['state'] == '') || (!isset($_POST['state']))) { exit(); // Or post error to let the user know then exit } else { Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/#findComment-1201945 Share on other sites More sharing options...
spiderwell Posted April 15, 2011 Share Posted April 15, 2011 I havent tested it, but wont this work too? if ((strtoupper($_POST['state']) == 'GA') || (empty($_POST['state']))) { exit(); // Or post error to let the user know then exit } else { Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/#findComment-1201946 Share on other sites More sharing options...
Muddy_Funster Posted April 15, 2011 Share Posted April 15, 2011 Yip, probably. And it would be much neater and more efficient too, I just wanted to make it clear how to expand on the options of conditional checks in a simple way, so that the OP can see they can expand on the checks to cover whatever they need. Quote Link to comment https://forums.phpfreaks.com/topic/233781-php-form/#findComment-1201951 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.