Solved

Form doesn't refresh entered values when using back button

Posted on 2004-10-15
11
345 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 500 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
return false must be hit after calling certain command 10 43
I'm a Human captcha checkbox 13 39
links not working 2 25
title attribute 5 23
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

740 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