Re: if/else statement, form-check



Den 29.06.2006 20:47, skriblet David Haynes følgende:
Ørjan Langbakk wrote:
[snip]
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


You seem to think this is a short-coming of the PHP language.
Do you have this coded in another language? If so, can you share that?

I profess that there has been so many messages back and forth about
this, that I am no longer sure what you are asking for.

Can you supply a set of input conditions (using email and phone) and
what you expect the outcome to be? From you latest post, it sounds like
you want to evaluate a quad-state logic condition with if-then-else
logic in a single pass, but I am so confused at the moment, that would
be a 'best guess' as to what you want.

Okay - I don't have access to the code right now, but I can try to explain a little better.

I have a form, with several fields: name, address, email and phone.

When the user submits the form, I need him to have put down at least his name and _either_ his email, address or phone number, so we have a sure way to get in contact with him.

That's why, while validating the form-data, I would like to process _first_ the name, and if there is no name entered, then I'll show an error - if there _is_ a name entered, I go to the next part, which is to check if there is an email-address entered - if there isn't, I want to go to the _next_ part, check if there is a phonenumber entered, if there isn't a phonenumber either, I want to show an errormessage - if there _is_ a phonenumber entered, then that will be sufficient, and the final check, for the valid numbers from a code-field will be checked - if erroneus, I'll display an error, if correct, the form will be processed.

As of now, I have chosen to have name, email and phonenumber as obligatory fields - they all get checked, and they all need input or the error-page displays. That works, of course, but I would like to have the above solution, as that would be more flexible towards the users.

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



Relevant Pages

  • Re: if/else statement, form-check
    ... check if both are empty (invalid), ... Why doesn't PHP have an if/then/else way of doing things... ... As of now, I have chosen to have name, email and phonenumber as obligatory fields - they all get checked, and they all need input or the error-page displays. ... you are looking for flexible input validation scheme based upon an arbitrary set of values where some values have an 'either of' relationship. ...
    (comp.lang.php)
  • Re: if/else statement, form-check
    ... if both are empty (invalid), ... can I do a check for criteria two _before_ the redirect? ... if code valiates, then send mail ... you want to evaluate a quad-state logic condition with if-then-else ...
    (comp.lang.php)