chiefrokka Posted May 29, 2009 Share Posted May 29, 2009 I have about 30 text fields... upon testing them when they click Submit, I want them to go back and fix the error. Every time I click Back though the fields are gone and they all have to be entered again. very unfriendly. I'm gathering I could make a link they click to go back and pass all 30 text fields with the variables i got from _Post... but is there an easier way than doing index.php?var1=$var1&var2=$var2, etc. (because that would be very tedious) Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/ Share on other sites More sharing options...
gevans Posted May 29, 2009 Share Posted May 29, 2009 Store them in a session? Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844968 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 dont force users to press Back if there is an error, perhaps one of my biggest pet peeves about form registrations online. The easiest way to fix this would be to submit the form to the same page for processing. If there is an error, just output the form again with all of the (correct) values already inputted and error messages near the incorrect ones Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844972 Share on other sites More sharing options...
chiefrokka Posted May 29, 2009 Author Share Posted May 29, 2009 Quote dont force users to press Back if there is an error, perhaps one of my biggest pet peeves about form registrations online. The easiest way to fix this would be to submit the form to the same page for processing. If there is an error, just output the form again with all of the (correct) values already inputted and error messages near the incorrect ones that's what I'm trying to do, just trying to find the easiest code to do this. I usually submit to same page and test if they clicked Submit. If they did, i run the code and display succes/error messages.. if they didn't, i display form. I could use sessions I suppose Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844979 Share on other sites More sharing options...
chiefrokka Posted May 29, 2009 Author Share Posted May 29, 2009 If they DIDN'T click Submit, I grab all the values from database that they already set and my form displays the $row['var1'], $row['var2'] etc. I guess I could just copy and paste the whole form and change all those initial values to be $_POST['var1'], $_POST['var2'] ?? Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844984 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 there is nothing to copy and paste, just use the same exact form with conditionals to display the data only if this is part of the submission process. <input type='text' name='persons_Name' <?php if($submit) { echo "value=\"$_POST['persons_Name']\""; } ?> > Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844987 Share on other sites More sharing options...
chiefrokka Posted May 29, 2009 Author Share Posted May 29, 2009 Quote there is nothing to copy and paste, just use the same exact form with conditionals to display the data only if this is part of the submission process. <input type='text' name='persons_Name' <?php if($submit) { echo "value=\"$_POST['persons_Name']\""; } ?> > I suppose that would be easiest. and just put an else in there to display db values instead if they didn't click submit. thanks Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-844989 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 please mark the topic Solved if you have no other queries on this Quote Link to comment https://forums.phpfreaks.com/topic/160153-solved-keeping-form-variables-when-you-click-back/#findComment-845000 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.