forms - reloading form and filling in last entered options
Posted: Sat Jun 04, 2005 11:14 pm
Hi there,
I have a form, it has checkboxes, radio buttons, text fields, drop down lists and a submit button.
When the user hits that submit button it reloads the form, checks over the data to see if the user has filled in 'all the blanks' as it were and if they haven't displays in red text what they didn't fill in.
This is all good and works well, but it also displays the form with no options checked/filled in. So the user now has to go and re-fill in all their data.
I'm after a way to have the page re-load, do the error checking as it does, but re-fill in the values passed in the POST array.
I should note that the forms are built dynamically from a database, an example might be this radio group:
This means that the form still needs to draw dynamically as it does, but be intercepted by the previous post data (if it exists) and draw it with the users last posted variables.
I've had a look at this kind of solution: http://www.evolt.org/article/Clever_for ... /17/60143/ but in all honesty, it's not for me. It's a rather complicated little function whereas I'd like to do conditional checks with PHP only on each step of the form draw. Keeps it simple for a PHP simpleton like me and it keeps java out of it.
So I'm here asking for advice as I've searched and thought and scoured my brain and basically, could do with some pointers in the KISS theory
Thanks for your time, I hope someone out there has an idea!
Rob
I have a form, it has checkboxes, radio buttons, text fields, drop down lists and a submit button.
When the user hits that submit button it reloads the form, checks over the data to see if the user has filled in 'all the blanks' as it were and if they haven't displays in red text what they didn't fill in.
This is all good and works well, but it also displays the form with no options checked/filled in. So the user now has to go and re-fill in all their data.
I'm after a way to have the page re-load, do the error checking as it does, but re-fill in the values passed in the POST array.
I should note that the forms are built dynamically from a database, an example might be this radio group:
Code: Select all
<?
mysql_select_db($dbname);
$sql = "SELECT * FROM table_name ORDER BY id ASC";
$content = mysql_query($sql);
$Xcontent = mysql_fetch_array($content);
$cShowMax = mysql_num_rows($content);
for ($y=1; $y<=$cShowMax; $y++)
{
$id = $Xcontent["id"];
$we_are = $Xcontent["we_are"];
echo "<label><input type=\"radio\" name=\"we_are\" value=\"$we_are\">$we_are</label><br>";
$Xcontent = mysql_fetch_array($content);
}
mysql_free_result($content);
?>I've had a look at this kind of solution: http://www.evolt.org/article/Clever_for ... /17/60143/ but in all honesty, it's not for me. It's a rather complicated little function whereas I'd like to do conditional checks with PHP only on each step of the form draw. Keeps it simple for a PHP simpleton like me and it keeps java out of it.
So I'm here asking for advice as I've searched and thought and scoured my brain and basically, could do with some pointers in the KISS theory
Thanks for your time, I hope someone out there has an idea!
Rob