Solved

Saving Dynamic Web Page Data without Submit?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 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

10 Experts available now in Live!

Get 1:1 Help Now