I do this sort of thing all the time.  The format I use typically 
follows this logic.

The PHP file has four IF-ELSEIF-ELSE sections.
    pg=1 or blank  is the initial form
    pg=2 is the error check looking at input values.
        If it passes, pg is set to 3.
        If not, set to 1. The advantage of this is the original input 
values can be saved and displayed with Value=<? ECHO..?> sequences so 
the use doesn't have to input everything if they make a mistake.  The 
error can be highlighted with a color or text!!!.
    pg=3 shows a visual verification page. The user can scan the input 
and use the back button to make changes or click OK to proceed.
    pg=4 is the action step - send an e-mail including the input, post 
input to a database or ???

The sections are written in this order - 2, 4, 3, 1.

        { do the error checking
        e.g., if fields A, B, and C are not blank = OK
        e.g., if a value is > 100 = not OK
           IF OK, $pg=3;  IF not OK, $pg=1;
        { do the action stuff.
        { show an html page in a nice format showing the input values
           IF they like it, the form submit button sets pg=4, and 
uses hidden fields to copy all of the input values to pg 4.
        { Show the initial input form.
        use <INPUT TYPE="HIDDEN" NAME="pg" VALUE="2">

The form can include error check and input tags like this:

<? IF(($pg="1") and ($val3==""))
     { ECHO"<FONT COLOR=RED>Required.</FONT><BR>"; } ?>
<TEXTAREA WRAP="SOFT" NAME="val3" COLS="50" ROWS="5"><? ECHO "$val3"; 

<INPUT TYPE="RADIO" NAME="v2" VALUE="6" <?IF($v2=="6") { ECHO 
"CHECKED"; } ?> >6
<INPUT TYPE="RADIO" NAME="v2" VALUE="7" <?IF($v2=="7") { ECHO 
"CHECKED"; } ?> >7

and so on.  Hope this is useful...

>Im trying to introduce some logic into a form.I am unsing $PHP_SELF 
>as the target.
><form action=\"$PHP_SELF\" method=\"POST\" type=\"multipart/form-data\">
>I have a text area that the user inputs their age.  What I want is 
>that if the field is blank, to stop the script and send the user 
>back to fill in their age.  My problem now is that if I go to the 
>blank application form, The script interprets the form as being 
>blank and spits out the error.  Ideal scenario, a blank form is 
>presented to the user, and when the form is submitted, do the logic 
>check and act accordingly.  Is it possible using $PHP_SELF as the 
>target, or do I have to use 2 files: a form 'front end' with the php 
>logic in the 'backend'??
>if ($Age = " ") {
>         echo "Please go back and enter your age."; } exit();
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


    Michael Seely      408-777-9949


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to