Re: [PHP] dynamic forms
If you have their ID when you generate the HTML FORM, there is no need for anything as exotic as Ajax... //get their $ID //query the DB using $ID to get $whatever echo "", htmlentities($whatever), ""; If you don't know their ID until the interact with other form elements, then, yeah, go with Ajax... But it would be pretty odd authentication mechanism that a front-end form would "know" my ID correctly and safely with no server-side interaction! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic forms
[snip] I would like to create a from that will pull and display information based on a user's ID from a postgresql database into a textarea on the form, before the submit button is clicked. Are there some tutorials on how to use PHP to dynamically display information on a form as the form is being filled out? [/snip] Google for Ajax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic forms
I would like to create a from that will pull and display information based on a user's ID from a postgresql database into a textarea on the form, before the submit button is clicked. Are there some tutorials on how to use PHP to dynamically display information on a form as the form is being filled out? Thanks Marc
Re: [PHP] Dynamic Forms
On Friday, January 16, 2004, at 02:15 AM, Robert Temple wrote: Can anyone suggest a PHP solution to creating a form that gets built after a client enters a variable? For example: an automobile insurance form that first asks how many cars you have, and then creates a form with fields for car 1, car 2, etc. I have found JavaScript code that will do this, but I would rather use a server side language like PHP for more consistency and browser compatibility. step1.php --- How many cars do you own? --- step2.php --- $i=0; while($i < $_POST['numberOfCars']) { $i++; echo "car number {$i}"; echo "Make "; echo "Model "; echo ""; } ?> --- This will produce an array of cars ($car[1] to $car[n]), each of which is an array of two elements make and model. Haven't done any work with arrays? Now is a good time :) step3.php --- --- This code is there just to show you the array structure... you'd change it to ad items to a database, etc. Example output: --- Array ( [car] => Array ( [1] => Array ( ["make"] => datsun ["model"] => 1600 ) [2] => Array ( ["make"] => toyota ["model"] => corolla ) [3] => Array ( ["make"] => honda ["model"] => civic ) ) ) --- Good luck :) Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Forms
Matt Matijevich wrote: [snip] Can anyone suggest a PHP solution to creating a form that gets built after a client enters a variable? [/snip] php runs on your server so to build the forms based on a user entered form field, the form has to be submitted, so you would have to use javascript to automatically submit the form or have the user push a submit button to susbmit the form so php can do its thing. I don't have a solution or tutorial per se'... Google might. Here is a small example of a self processing form, if it helps. "; } elseif((!empty($_POST['var01'])) || (!empty($_POST['var02']))) { $form = " "; } else { $form = "$_POST[var01] $_POST[var02]"; } echo $form; ?> Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Forms
[snip] Can anyone suggest a PHP solution to creating a form that gets built after a client enters a variable? [/snip] php runs on your server so to build the forms based on a user entered form field, the form has to be submitted, so you would have to use javascript to automatically submit the form or have the user push a submit button to susbmit the form so php can do its thing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic Forms
Can anyone suggest a PHP solution to creating a form that gets built after a client enters a variable? For example: an automobile insurance form that first asks how many cars you have, and then creates a form with fields for car 1, car 2, etc. I have found JavaScript code that will do this, but I would rather use a server side language like PHP for more consistency and browser compatibility. Any help would be appreciated! - Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php