tmcdonnell Posted September 12, 2011 Share Posted September 12, 2011 Hi, So i have a form with 4 text inputs (input1,input2,input3,input4). When the user puts in 4 correct words, they are redirected to another page. The words can be checked either via a field in a database or a variable. Any wrong word in any of the text fields returns the user back to the page. In other words: When the user clicks submit, we need to make sure all of the words are correct. If they are not correct, nothing should happen. The user will remain on the page until they enter the correct words. If the words ARE correct, they are directed to a new page with an image. I am not sure how to approach this, I tried using if and case, however I am not sure of the combination to make all 4 fields checked before an out is given (ie, the page redirect). Any help is appreciated. Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/ Share on other sites More sharing options...
Pandemikk Posted September 12, 2011 Share Posted September 12, 2011 Really? <?php if ( !isset($field_1) OR !isset($field_2) OR !isset($field_3) OR !isset($field_4) ) { // go back to your page } if ($field_1 != 'what it should') { // go back to your page } if ($field_2 != 'what it should') { // go back to your page } if ($field_3 != 'what it should') { // go back to your page } if ($field_4 != 'what it should') { // go back to your page } // go to the result page ?> I must be missing something. It can't be as simple as I think it is. Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/#findComment-1268571 Share on other sites More sharing options...
tmcdonnell Posted September 13, 2011 Author Share Posted September 13, 2011 I need to compare the fields. if ( input1="yes"; input2="no"; input3="maybe"; input4="yes"; then header redirect "well done"; else header "go back to text input page"; ) Something like that, except this don't work =) Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/#findComment-1268572 Share on other sites More sharing options...
Pandemikk Posted September 13, 2011 Share Posted September 13, 2011 ? <?php if ($input1 == "yes" AND $input2 == "no" AND $input3 == "maybe" AND $input4 == "yes") { // redirect - well done } else { // redirect - go back to text input page ) ?> Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/#findComment-1268575 Share on other sites More sharing options...
tmcdonnell Posted September 13, 2011 Author Share Posted September 13, 2011 Thanks Pandemikk ! It was a simple solution that was driving me up the wall. Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/#findComment-1268576 Share on other sites More sharing options...
Pandemikk Posted September 13, 2011 Share Posted September 13, 2011 No problem. Be sure to mark as solved. Link to comment https://forums.phpfreaks.com/topic/247013-compare-4-text-fields-and-return-page-if-correct/#findComment-1268578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.