Re: if/else statement, form-check
- From: David Haynes <david.haynes2@xxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 11:43:40 -0400
Jerry Stuckle wrote:
David Haynes wrote:Jerry:Marcin Dobrucki wrote:
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.Isn't this just:
I do not wish to redirect after the first false, but after the second.
Have I misunderstood something, or?
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.
I don't see how 'if (!email || !phone) redirect;'
handles this case:
"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."
The || would say that you will redirect if *either* email or phone is not set.
With my code, if both are not set, then the redirect occurs.
If you continue past the if() then you know either email or phone (or both) is set.
So you just take the action based upon that knowledge with a precedence given to the email.
-david-
David,
If you want to redirect if both are invalid, just do:
if(!email && !phone)...
That's what I said... ;-)
-david-
.
- Follow-Ups:
- Re: if/else statement, form-check
- From: Ørjan Langbakk
- Re: if/else statement, form-check
- References:
- if/else statement, form-check
- From: Ørjan Langbakk
- Re: if/else statement, form-check
- From: BKDotCom
- Re: if/else statement, form-check
- From: Ørjan Langbakk
- Re: if/else statement, form-check
- From: David Haynes
- Re: if/else statement, form-check
- From: Marcin Dobrucki
- Re: if/else statement, form-check
- From: David Haynes
- Re: if/else statement, form-check
- From: Jerry Stuckle
- if/else statement, form-check
- Prev by Date: Re: font problems in ezPDF
- Next by Date: Re: if/else statement, form-check
- Previous by thread: Re: if/else statement, form-check
- Next by thread: Re: if/else statement, form-check
- Index(es):
Relevant Pages
|