Solved

Saving Dynamic Web Page Data without Submit?

Posted on 2003-10-28
3
260 Views
Last Modified: 2012-05-04
I'm using PHP and MySQL - I have an email form which the user fills in the To:, Subject and Body then clicks on submit - the problem is that a lot my users are starting to fill out the form and then they click on the Back button and then the forward button (don't ask me why) and the data they typed in is gone!! They don't understand how dynamic web pages work vs static pages, etc. Is there a way for me to save the data to my php variables before the user clicks the submit button so that when they Fwd back to the page I can restore the data that was there?

Thanks...
0
Comment
Question by:rfresh
[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
3 Comments
 
LVL 13

Expert Comment

by:lozloz
ID: 9638344
this is probably more a javascript question than a php question.. my javascript ain't so hot so i don't know if it can done but i'd imagine you'd have to have an event which relates to browsing away from the page to store the information in a cookie and then load it up again.. this isn't very easy and seems like a lot of effort, maybe just a simple message at the top saying "don't browse away from this screen before completing the form" would be more appropriate?
0
 
LVL 2

Expert Comment

by:errows
ID: 9639568
Using the onUnload event with javascript, you should be able to save all your form's data.
You can also use onChange on every field, wich might be less efficient...

http://www.devguru.com/Technologies/ecmascript/quickref/evhan_onunload.html

errows
0
 
LVL 1

Accepted Solution

by:
de_wagter earned 125 total points
ID: 9784941
a regular form should not loose it's contents when hitting back and forward. However if you set the page to be expired, then browsers don't cache anymore, and also, if special javascript functions are called to submit the form or loading your page, this also happens.

<html><body>
<form method=post>
<input type=text name=test>
<input type=submit>
</form></body></html>

A simple form like this one should NOT lose its contents hitting back and forward. (please tell me if it does with you!)

If this one keeps its contents, then check your site for any META like no-cache, headers definitions with expire, javascritps changing form values etc...

If this doesn't help you can always post the form using the onUnload even as errows proposed, and keep it in some session variable for example...
0

Featured Post

Industry Leaders: 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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

756 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