Re: Dynamic Forms
| From: | Jas | Date: | Thu, 15 Jan 2004 15:45:00 +0000 |
| Subject: | Re: Dynamic Forms | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174664@lists.php.net to get a copy of this message | ||
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.<?php if((empty($_POST['var01'])) || (empty($_POST['var02']))) { $form = "<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input name=\"var01\">
<input name=\"var02\">
<input type=\"submit\" value=\"Save\">
<input type=\"reset\" value=\"Reset\">
</form>";
} elseif((!empty($_POST['var01'])) || (!empty($_POST['var02']))) {
$form = "<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input name=\"var01\" value="\$_POST[var01]\">
<input name=\"var02\" value="\$_POST[var02]\">
<input type=\"submit\" value=\"Save\">
<input type=\"reset\" value=\"Reset\">
</form>";
} else {
$form = "$_POST[var01]
$_POST[var02]"; }echo $form; ?> Jas