So far this message and another who mentioned $HTTP_POST_VARS[]
made a small light go off in my head. Not enough to get the script
woriking, but it made me think. Its not clear, but I sort of came up
with another way, but I dont know if its doable
.
In my form I have a hidden element called 'post' with a value of 1.
After the end of the form I echo $post.
If its a first time view, there is nothing to output, thats normal.
If I submitted the form it echoes 1, thats to be expected.
Now, Im able to tell if the form has been posted or not.
Enter some logic......
if ($post = "1" && $Age = " ") {echo "NO";}
else {echo "YES";}
Now here is what happens. On a first time view of the page it outputs
'NO' (Good). If I dont enter anything in the age field and submit the
form it outputs 'NO' (Good). If I enter a value into the age field and
submit, it outputs 'NO' (Not Good).
Am I heading in the right direction with this??
Michael J. Seely wrote:
> 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.
>
> IF($pg="2")
> { 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;
> }
> ELSEIF($pg="4")
> { do the action stuff.
> }
> ELSEIF($pg="3")
> { 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.
> }
> ELSE
> { 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";
> ?></TEXTAREA>
>
> <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();
>>
>> Thanks
>> Gerard
>>
>>
>> --
>> 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]
>
>
--
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]