[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Form doesn't refresh entered values when using back button

Posted on 2004-10-15
11
Medium Priority
?
349 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

650 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