Re: quick form question
| From: | Kondwani Spike Mkandawire | Date: | Thu, 08 Aug 2002 16:47:41 +0000 |
| Subject: | Re: quick form question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111684@lists.php.net to get a copy of this message | ||
"Alexander Ross" <alexross@bleen.net> wrote in message
news:20020808162929.17218.qmail@pb1.pair.com...
> I have a .php with a simple form in it to populate a table in a mysql db.
> When the user clicks submit, I check to make sure he/she entered the
> required info and if all is well, I add the data to teh DB. If he/she
left
> out some info, I echo "You left out some info" and I redisplay the form.
> When I do this all the info that the user typed originally is gone. Whats
> the easiest way to put back what he/she already typed? Thanks
>
I am not sure of what you require but will respond according to my
understanding...
I am assuming your send page is to the same page...
i.e. If you have myForm.php coding the form you have something as follows:
<? //myForm.php
echo '<form name = myForm action=myForm.php method=post>';
if((empty($var1))||(empty($var2))||....{
if(empty($var1)){
echo '<input name = var1 .... >';
}
// Notice the locking of Strings So as not to lose
// info when the page is sent... This is done
// by the backslashes...
else{
echo "<input type = hidden name = \"var1\" value =
\"var1\">";
if(empty($var2)){
echo '<input name = var2 ... >';
}
else{
echo "<input type = hidden name = \"var2\" value =
\"var2\">";
}
echo ' ...The Submit button...';
}
else{
....
// Algorithmically...
... Now you can connect to your DB and Place the variables
in their appropriate fields via php and SQL Query commands...
echo "DONE!";
}
This way only the unfilled fields that you deem neccessary will
reappear and Whatever she has already entered is stored as a
hidden variable but will be visible when need for use...
Hope this helps...
Spike...