Re: single page form

From: Date: Thu, 26 Oct 2000 00:13:33 +0000
Subject: Re: single page form
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3906@lists.php.net to get a copy of this message
Here's a quick script that will give you an idea of what is going on: --------------------------------------------------------------- <? /* As you can see this is a rudimentary example, but it should give you a basic idea of how to proceed with something like this. If you add some looping and session variables you will understand how you can expand this (very) simple script into a larger system. If you have any questions or comments/flames feel free to email me at alessio@mvfx.com Oh yeah... I don't think some of these things will work in PHP3 but it's been a while so I can't remember exactly. */ /* For this example we'll set a variable named $user_input equal to $HTTP_POST_VARS (This could just as easily be something like $HTTP_GET_VARS if you prefer passing variables in the query string. You could also just access these variables directly by name but this way will be easier for an example.) */ $user_input = $HTTP_POST_VARS; /* Let's print that out to see what we got - should be blank the first time through */ ?><hr><pre>Dumping $user_input<br><? print_r($HTTP_POST_VARS); ?></pre><hr><? /* Set up our <FORM> that will allow us to post information back to this script every iteration. */ ?><FORM METHOD="POST" ACTION="<?=$PHP_SELF?> "><? /* If the user pushed a button that we called 'second_button' */ if(isset($user_input['second_button'])) { ?>The total of the two numbers is: <B><?=($user_input['first_number'] + $user_input['second_number'])?><BR><? } /* If the user pushed a button that we called 'first_button' */ elseif(isset($user_input['first_button'])) { ?> Second Number:<INPUT TYPE="TEXT" NAME="second_number" VALUE=""><BR> <INPUT TYPE="HIDDEN" NAME="first_number" VALUE="<?=$user_input['first_number']?>"> <INPUT TYPE="SUBMIT" NAME="second_button" VALUE="Click Me"> <? } /* The user didn't push any buttons that we were expecting so start from beginning. */ else { ?> First Number:<INPUT TYPE="TEXT" NAME="first_number" VALUE=""><BR> <INPUT TYPE="SUBMIT" NAME="first_button" VALUE="Click Me"> <? } /* Close the form tag */ ?></FORM><? ?> --------------------------------------------------------------- ----- Original Message ----- From: "Adv. Systems Design" <asd_2000@yahoo.com> To: "Php-Db" <php-db@lists.php.net> Sent: Monday, October 23, 2000 4:43 PM Subject: [PHP-DB] single page form > Hello: > > I think this must be a FAQ...I see alot of PHP forms > that gather user input without calling another page > (it calls itself), all the while passing the collected > variables to the url string...does anyone have a form > like that where I could see the structure? What is the > basic logic in a page like that? > > If you could point me to some source that could be > dissected I would really appreciate it... > > Thanks > Luis

« previous php.db (#3906) next »