PaulM9 Posted November 5, 2011 Share Posted November 5, 2011 Hello Everyone, Looking for some help with a form losing user input when clicking the browser back button. I have the code working perfectly when people register (ie if they forget to complete a field, they are kicked back to the form, and their other input is still there), however once a user logs into the site and wants to create a MySQL record using another form, if they leave a field empty and they get kicked back to fill in the blank field, all their other inputs are gone and they have to start filling the entire form again. I use the same logic for both, but one does not work. Any clues as to what could be wrong in the second scenario? if ($action=="add") { $dberror = ""; //add slashes to input so things don't get messed up in mySQL $city = addslashes($city); // check for blank fields if ($title == "") {die ("<P>Please select a title!<P><FORM><INPUT TYPE=\"BUTTON\" VALUE=\"BACK\" onClick=\"history.back()\"></FORM>");} elseif ($city == "") {die ("<P>Please enter your city / town!<P><FORM><INPUT TYPE=\"BUTTON\" VALUE=\"BACK\" onClick=\"history.back()\"></FORM>");} elseif ($state == "") {die ("<P>Please select your country!<P><FORM><INPUT TYPE=\"BUTTON\" VALUE=\"BACK\" onClick=\"history.back()\"></FORM>");} else //success! Go ahead and enter the record Then the record gets added to the MySQL database fine, no issues here. Further down the code is the input section, and I use this method: print "<form name=\"addlisting\" action=\"./agentadmin.php?action=add\" method=post>"; ….code for date entry here – standard stuff. print "<input type=submit value=\"Submit\"></form>"; Thank you, Paul. 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.