September 13, 2012
if else with an optional value
Question by Elliott
I can’t figure this out. I need to do and if else.
If A is not empty then it must equal B & C must = D & E must = F
It is the A & B part I think that has me messed up. I cant get it to work only if A is not empty
if( ( !empty($data[0]) && trim($data[0]) == $_POST['firstname'] ) || trim($data[1]) == $_POST['lastname'] && $_POST['password'] == $password)
It is that A is optional that gets me.
Answer by andrewsi
Why do it all in one go?
If (A is not empty) then
if A == B && C == D && E == F then
Which I think comes out as:
if ( !empty($data[0]) {
if ((trim($data[0]) == $_POST['firstname'] ) && trim($data[1]) == $_POST['lastname'] && $_POST['password'] == $password) {
Answer by Starx
It would be something like this:
if( !empty($a) && ($a==$b && $c == $d && e == $f)) {
// Carry On
}