Reply to Re: if/else statement, form-check

Your name:

Reply:


Posted by Ψrjan Langbakk on 11/08/22 11:52

Den 29.06.2006 17:43, skriblet David Haynes fΓΈlgende:
> Jerry Stuckle wrote:
>> David Haynes wrote:
>>> 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.
>>>>>>
>>>>>> 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.
>>>
>>> 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)...

I might be dense, but it still isn't the problem. Of course I can check
if both are empty (invalid), that's easy.

Why doesn't PHP have an if/then/else way of doing things... or, can I do
a check for criteria two _before_ the redirect?

something like:
if (not valid)
then (check criteria two)
if both = invalid, then redirect
if both = valid, then -> check code
if code valiates, then send mail


--
mvh
Ørjan Langbakk
http://www.bergenpchjelp.no
http://www.cubic-design.net

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация