Jump to content

Browser back button loses user input


PaulM9

Recommended Posts

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.