i want a if statement to check if both fields have data, I have this..
It always does "do this" no matter what.. why?
If (isset($POST['Name']) && (isset($POST['Phone'])){
.. do this
} else {
... else..
{
Use empty instead of isset. (Of course, you have to change the expression slightly.)
Narr still does not work
if (empty($_POST['Name']) && empty($_POST['Number']) && empty($_POST['Date']) && empty($_POST['Type']) && empty($_POST['Reason']) && empty($_POST['Address']) && empty($_POST['Email']) && empty($_POST['Level'])){ echo "rr"; } else { echo "hh"; }
I also get the HH stuff
That's because you are testing to see that they all ARE empty.
Sorry, how about
if (empty($_POST['Name'] or empty($_POST['Phone'])){ echo "Error"; } else { .... }
I get error when I leave one of the feilds blank... why?
NZ_Kiwis;10939279 wrote:i want a if statement to check if both fields have data, I have this..
NZ_Kiwis;10939279 wrote:Sorry, how about I get error when I leave one of the feilds blank... why?
isn't that what you asked for in the first place?
First it was AND now it's OR
the code in #6 answers the question "i want a if statement to check if both fields have data"
by returning 'Error' if either is empty
yes now either one can be empty but not both. Sorry was i not very clear?
#6 code returns error if one or both are empty
I want a code to say only if both are empty
NZ_Kiwis;10939297 wrote:I want a code to say only if both are empty
then replace OR with AND