?
Solved

Form doesn't refresh entered values when using back button

Posted on 2004-10-15
11
Medium Priority
?
348 Views
Last Modified: 2006-11-17
Hi, I have an HTML form that a user fills in, and then it is submitted to a confirmation page.  Only problem is, if they click the back button to change something, the form is not showing their entered values.  I thought this was standard behaviour for browsers to do so.  Could anyone offer some ideas as to why it is not working, please?

Thanks!
0
Comment
Question by:earthman100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 11

Expert Comment

by:neester
ID: 12326056
Are you using PHP to control the form.

What you can do is.
have the forms like this:

<input type="text" name="username" id="username" value="<?=$_POST['username']?>" />

Then when they submit the form it will submit the values to itself.

So have something like this

<?

// form validation code here!!!

// if validated fine - then redirect (use this:
header('location: newpage.php');
exit;
// if not, show error message...
echo("your form didnt validate!");
?>
<form action="thispage.php" method="post">
<input type="text" name="username" id="username" value="<?=$_POST['username']?>" />
<input type="text" name="username" id="username" value="<?=$_POST['username']?>" />
<input type="text" name="username" id="username" value="<?=$_POST['username']?>" />
<input type="text" name="username" id="username" value="<?=$_POST['username']?>" />
</form>


Does that make sense??



its obviousl really cut up and short.
but if you are using PHP it will probably make sense to you!
0
 
LVL 11

Expert Comment

by:neester
ID: 12326057
this way - they wont need to hit backj
0
 

Author Comment

by:earthman100
ID: 12326078
I have used that before, but I do not want to do that.  I am sending the form to another page that confirms the info they entered in a text version.  I just want the back button to work the way it should, and cannot figure out why it won't.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:neester
ID: 12326086
Its a browser issue.
I dont think there is anything you can do.
Perhaps change the form from POST to GET...
0
 

Author Comment

by:earthman100
ID: 12326145
Well, it's unfortunate to see you dismiss things so easily.

It is not a browser issue.  Through debugging it I believe I have discovered that it has something to do with the javascript that I am using on the page, not with the form itself.  

That is simply the answer I was looking for, as I know that the browser's back button works fine with forms as it's meant to...that hasn't changed.

Thanks anyways.
0
 

Author Comment

by:earthman100
ID: 12326167
AHA...it was the PHP command:

session_start();

that caused it not to reload the values.  Wish I knew why, if anyone can tell me I will award them the points.

Anyways, mystery solved.
0
 
LVL 11

Expert Comment

by:neester
ID: 12326279
EarthMan.
Sorry - Logically it seems that it wouldnt be anything Server Side - that is why I said it would be browser based.
If you hit back, it shouldnt actually reload any content.
It should just load the cache...

odd...
sorry.
0
 
LVL 12

Accepted Solution

by:
minichicken earned 2000 total points
ID: 12326327
Hi

Are you using IE??
Take a look at http://www.phpfreaks.com/tutorials/41/1.php about Microsoft Internet Explorer Sessions Fix.

If you are using session_start(); then you also need to use header("Cache-control: private"); below it, to avoid the IE bug

So you have this if you use sessions on that page

session_start();
header("Cache-control: private"); //IE fix

regards
0
 
LVL 11

Expert Comment

by:neester
ID: 12326329
Seeing as I dont use IE.
Thats probably your answer there :)
0
 

Author Comment

by:earthman100
ID: 12326387
perrrfect.  Thanks minichicken!
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12326513
Great Stuff.... No prob.. :)
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question