Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving Dynamic Web Page Data without Submit?

Posted on 2003-10-28
3
Medium Priority
?
265 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
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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

877 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