PDA

View Full Version : A little help with PHP!



ben0
08-19-2008, 05:08 AM
Hi Guys and Girls,

Need a little help with PHP and re-submitting Form data.

I have a site which allows users to submit different information via standard forms using request type. They work OK with no problems. The problem is when they are typing these lengthy forms out there session will time out and when they click submit the site for forward them to re-enter their password and they lose all the form data and I get shouted at :down:

So I've managed to capture the form data and the url and dumped it into an array in their session. But I can't figure out how to get the data resubmitted to the form. :shrug:

Any guidance or help much appreciated!

Thnx

ben0
08-19-2008, 11:21 AM
Quick update, I used the Pecl http extension with the function http_post_fields(). But now when the script tries to post the data to the script the script bins it out and tries to forward it to the login page! :shrug:

acidpython
08-20-2008, 12:41 AM
try googling about sticky forms... i think thats what your on about?

If you don't get any luck i'll reread a tutorial i read a while back.

sigt
08-20-2008, 04:24 AM
Try to add a hidden iframe with an auto-refreshing page, that keeps the session alive.

Teqqles
08-21-2008, 04:50 AM
You could always store the results in a data store linked with that user account (assuming you are losing session data), then when they log in add a task to recover any partially complete forms and add the data via hidden fields in the resulting form page...

There are actually a number of solutions to a problem like this, but the simple ideas are usually the best

W1zzard
08-21-2008, 11:32 AM
why do you even have such a short session timeout in the first place? your best bet is a refreshing iframe or a repeat ajax request (requires javascript though)

ShadedNine
08-24-2008, 10:58 PM
The code for the form page should be set up to read from the appropriate POST|GET params into the form data. Then, they post the form and it sends the form data to the login page (where it doesn't do anything of course). Now you need to make sure the login page mirrors incoming POST/GET parameters, as well as the referring page. Then, when they log back in, all their parameters will be passed unchanged back to the referring page, which in the case of your form, will repopulate the data.

Ideally though, your login check should occur AFTER they post the form (in whatever page processes it). This way, that page becomes the referrer, and after logging in, the user doesn't have to resubmit the form, it goes right to the processing stage.

ben0
09-21-2008, 12:08 PM
Thanks for your comments folks, much appreciated! I'm still finding my way around PHP and stuff :-) Bit of a noob!

Sorry for the late reply! Thanks again!