Jump to content

help with operator to validate a form


co.ador

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.