co.ador Posted January 21, 2010 Share Posted January 21, 2010 The validation test belowin will only validate if all the fields are filled. I want that if only one is true then print as well. in other words the user doesn't have to fill all the fields to get some results, it won't get a more specific match but will get some. <?php if ( trim($_POST['name']) == '' && $_POST['zipcode'] =='' && $_POST['state'] =='' && $_POST['frmSearch']['types'][0]=='' && $_POST['frmSearch']['offerings'][0]=='') { echo '<div id="tresuno">'; var_dump($_POST); echo'<p class="tremendi">No results for your match please try again!</p> <div id="tresdo"> <a href="index.php"><< Go Back</a> </div>';} else { //extract the variables from the url and dsiplay the list of restaurants }?> the script above will validate if only all the fields are filled. But I want that if one of the fields are filled and it is it match then print a list of restaurants that matches or at least has a similar match of that of the user input. I was thinking that the operator && is forcing the user to fill all the fields? would the operator & be effective for this case? Link to comment https://forums.phpfreaks.com/topic/189378-help-with-operator-to-validate-a-form/ Share on other sites More sharing options...
teamatomic Posted January 22, 2010 Share Posted January 22, 2010 Drop the entire if/else statement and just work with what you would have in your else. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189378-help-with-operator-to-validate-a-form/#findComment-999668 Share on other sites More sharing options...
co.ador Posted January 22, 2010 Author Share Posted January 22, 2010 the else statement will work, but then it will submit if all the fields are empty. it's that an issue at all? Link to comment https://forums.phpfreaks.com/topic/189378-help-with-operator-to-validate-a-form/#findComment-999671 Share on other sites More sharing options...
teamatomic Posted January 22, 2010 Share Posted January 22, 2010 Then keep the logic and in the else work with only posted data that has value. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189378-help-with-operator-to-validate-a-form/#findComment-999675 Share on other sites More sharing options...
co.ador Posted January 22, 2010 Author Share Posted January 22, 2010 can you do a little illustration please. Link to comment https://forums.phpfreaks.com/topic/189378-help-with-operator-to-validate-a-form/#findComment-999676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.