DarkPrince2005 Posted May 24, 2010 Share Posted May 24, 2010 I've got a form that is generated x-amount of times, x being selected from a drop down. But everytime the form is submitted and the forms don't validate the user has to re-enter all thee data. Does anyone know how I can make the form remember the $_POST values of an array. e.g. <input value="$_POST["name"]" /> <div name="students" id="students"> <table align=center border=0 cellspacing=4 cellpadding=0 width=700px> <input type="hidden" name="student_tot" value="1"> <tr> <td align="left" colspan="4">Student 1: <br><hr></td> </tr> <tr> <td><FONT color=#ff0000>*</FONT> Title</td> <td width="23%"><?drop_down(array("Mr","Mrs","Miss","Dr","Prof"), "s_title[]");?></td> <td width="27%"><FONT color=#ff0000>*</FONT> Last Name</td> <td width="23%"><input class=FrmTextBox style="width: 100%" name="s_surname[]"></td> </tr> <tr> <td ><FONT color=#ff0000>*</FONT> First Name</td> <td ><input class=FrmTextBox style="width: 100%" name="s_name[]"></td> <td><FONT color=#ff0000>*</FONT> Birthday</td> <td> <? drop_days1('s_bday[]', date('d',strtotime($date1))); echo " "; drop_months1("s_bmonth[]", "to_day", $date1); echo " "; drop_years1("s_byear[]", $date1); ?> </td> </tr> <tr> <td> ID Number</td> <td><input class=FrmTextBox style="width: 100%" name="s_ID[]"></td> <td rowspan="2" valign="top"><FONT color=#ff0000>*</FONT> Postal Address</td> <td rowspan="2"><textarea class=FrmTextBox style="width: 100%" name="s_address[]"></textarea></td> </tr> <tr> <td> Tel (W)</td> <td><input class=FrmTextBox style="width: 100%" name="s_tel_w[]"></td> </tr> <tr> <td> Tel (H)</td> <td><input class=FrmTextBox style="width: 100%" name="s_tel_h[]"></td> <td> Fax</td> <td><input class=FrmTextBox style="width: 100%" name="s_fax[]"></td> </tr> <tr> <td><FONT color=#ff0000>*</FONT> Email</td> <td><input class=FrmTextBox style="width: 100%" name="s_email[]"></td> <td><FONT color=#ff0000>*</FONT> Cell</td> <td><input class=FrmTextBox style="width: 100%" name="s_cell[]"></td> </tr> </table> </div> Quote Link to comment Share on other sites More sharing options...
DarkPrince2005 Posted May 25, 2010 Author Share Posted May 25, 2010 anyone??? Quote Link to comment Share on other sites More sharing options...
ignas2526 Posted June 3, 2010 Share Posted June 3, 2010 What you need to do is to check if page being displayed after error, or if POST values are set. lets say we have that code: drop_down(array("Mr","Mrs","Miss","Dr","Prof"), "s_title[]"); I suppose second parameter is what must be selected in drop down. so lets say what input name of drop down box is 'title'. Then solution will be: drop_down(array("Mr","Mrs","Miss","Dr","Prof"), (isset($_POST['name'])?$_POST['name']:"s_title[]") ); or lest say we have variable $error_state what is set to true if we showing page after failed validation: drop_down(array("Mr","Mrs","Miss","Dr","Prof"), ($error_state?$_POST['name']:"s_title[]") ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.