keltik Posted January 17, 2012 Share Posted January 17, 2012 I'm new to php, so please excuse my ignorance. Here's my issue: On my website, I want to ask the following question to validate the person filling in the form is a real person: Which is the hottest: FIRE or ICE ? Right now, my code is only set to accept all caps - which is confusing some of my customers. How to I update the following code, to allow caps and lowercase answers? if (empty( $_POST['validate'] ) || !ctype_upper( $_POST['validate'] ) || ($_POST['validate']!="ICE" and $_POST['validate']!="FIRE")){ $errors->add('empty_username', __('<strong>ERROR</strong>: Please check your validation answer.')); } Link to comment https://forums.phpfreaks.com/topic/255240-help-with-validation-question/ Share on other sites More sharing options...
smerny Posted January 17, 2012 Share Posted January 17, 2012 put this above your code $_POST['validate'] = strtoupper($_POST['validate']) Link to comment https://forums.phpfreaks.com/topic/255240-help-with-validation-question/#findComment-1308643 Share on other sites More sharing options...
keltik Posted January 17, 2012 Author Share Posted January 17, 2012 I put what you gave me above if (empty( $_POST['validate'] ) || It's coming back with a syntax error though... told you I was new. Could you show me using my original code where this needs to go? Thanks so much! Link to comment https://forums.phpfreaks.com/topic/255240-help-with-validation-question/#findComment-1308659 Share on other sites More sharing options...
Muddy_Funster Posted January 17, 2012 Share Posted January 17, 2012 if (strtoupper($_POST['validate']) != 'FIRE'){ $errors->add('empty_username', __('<strong>ERROR</strong>: Please check your validation answer.')); } Link to comment https://forums.phpfreaks.com/topic/255240-help-with-validation-question/#findComment-1308662 Share on other sites More sharing options...
keltik Posted January 17, 2012 Author Share Posted January 17, 2012 That did it. Thanks!!!! Link to comment https://forums.phpfreaks.com/topic/255240-help-with-validation-question/#findComment-1308670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.