Solved

Saving Dynamic Web Page Data without Submit?

Posted on 2003-10-28
3
257 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now