Re: if/else statement, form-check



David Haynes wrote:
Ørjan Langbakk wrote:

See, I have, first, a check for existing email - if there is no email present, I want it to check if there is a phonenumber entered, and if _both_ those conditions are false, then I want to redirect.

I do not wish to redirect after the first false, but after the second.

Have I misunderstood something, or?

Isn't this just:

if( ! email && ! phone ) redirect;
if( email ) do_email
else do_phone

if (!email || !phone) redirect;
// if you are here, all is ok.

Redirect will happen only of both conditions fail. Ofcourse, it does have a side-effect that if email is valid, phone will never be checked because the condition for "if" will already satisfy.

Ofcourse, it doesn't hurt to have a small "isset" test on the whole thing, especially when we were talking about $_POST. If someone accesses the page via GET, condition would fail, and under some circumstances, just fall through.
.



Relevant Pages

  • Re: if/else statement, form-check
    ... David Haynes wrote: ... I do not wish to redirect after the first false, ... Redirect will happen only of both conditions fail. ... Ofcourse, it does have a side-effect that if email is valid, phone will never be checked because the condition for "if" will already satisfy. ...
    (comp.lang.php)
  • Re: if/else statement, form-check
    ... Jerry Stuckle wrote: ... I do not wish to redirect after the first false, ... Redirect will happen only of both conditions fail. ... Ofcourse, it does have a side-effect that if email is valid, phone will never be checked because the condition for "if" will already satisfy. ...
    (comp.lang.php)
  • RE: grabbing print output
    ... > close PIPE; ... How I can grab this, ... Redirect to a file and read the file: ...
    (perl.beginners)
  • Re: if/else statement, form-check
    ... Marcin Dobrucki wrote: ... I do not wish to redirect after the first false, ... Redirect will happen only of both conditions fail. ... Ofcourse, it does have a side-effect that if email is valid, phone will never be checked because the condition for "if" will already satisfy. ...
    (comp.lang.php)
  • Re: if/else statement, form-check
    ... David Haynes wrote: ... The || would say that you will redirect if *either* email or phone is not set. ... "Today I check for the existence of an email-address, and a validation code - what I need is a way to check, eg. whether email _or_ phone is entered, and if none is entered, display an errorpage." ...
    (comp.lang.php)