Caching form data

I'm building a database website using PHP, Dreamweaver CS3, and MySQL. It's based pretty much on built on Dreamweaver's built in dynamic content templates. The pages follow CS3's style in that they post to themselves, and if they encounter a mysql error, then they die() with some relevant error message.

Problem is, after the page dies, if I hit the back button on the browser the form is blanked out. I can't go back to what I had previously typed in before hitting submit.

I've seen IE and FF "cache" the text you had typed in in previous forms in their history, so when you go back, the text is still there. Is there a way to turn this on on my page? Or does anyone know the reason why it isn't happening on mine?

Note: I'm not talking about restoring the values of the textboxes using PHP and the $_POST array when a page comes back with validation errors. I mean using the browser's back button and showing an older, cached form with text in it.
LVL 31
Frosty555Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

adrpoCommented:

Hi,

I don't think you can base yourself on the cache for the forms.
If you go back you should rebuild the form data yourself to be
sure is still there.

As far as I know Internet Explorer doesn't save everything in the forms.
If you go back the forms will be empty. It has autocomplete, but that
doesn't work for the text areas.

Cheers,
za-k/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve BinkCommented:
The form cache is a client feature, not a server feature.  You can, of course, pre-populate all your form controls, but you have no way of knowing what the user entered until the form is POSTed.

One alternative is to not let the page die() on a database error.  Instead, record the error and send an alert, and allow the page to continue rendering.  That way, should be able to retain the POST information.
0
Frosty555Author Commented:
I know it isn't a 100% surefire anything, I was just looking for some way to preserve the data in a textfield... without having to go into every form I've created and add code to repopulate the data from the $_POST array.

I'm sure I've seen this before, even on my own websites, so not some website where they could be repopulating the data from the $_POST array. IE would remember some ir not all of the text you entered into a form. It might be that it is when you hit submit and the page encounters some error, like a 404 error, as opposed to actually reaching a new page...

Is there any kind of solution that doesn't involve me re-coding all my pages to fill default values into the form?
0
Steve BinkCommented:
As I said, the form cache is a client feature.  I'm sure you have seen it before, and I would suggest those sightings are examples of $_POST population, or your client retaining your entries.

The server has no way to know about the client's form cache, and would not have permission to access it if it did.  Unless the server receives $_POST data, or default data from another source (such as a database), you have no way to tap into previous entries.

Once you receive the $_POST data, you are left with programmatically inserting that data into the form controls.  
0
Frosty555Author Commented:
Damn. Well, I know how to do the $_POST repopulation, and I can remove the die() and replace it instead with an adding of data to an error property that I can display later in red in my form.

I just didn't want to edit every form I had made. Oh well.

Thanks everyone
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.