Forum Moderators: coopster

Message Too Old, No Replies

quick form question

         

bobnew32

2:40 am on Dec 3, 2003 (gmt 0)

10+ Year Member



I have a form that when I click submit its fine. But when I notice somthing I want to go back and change, when I hit back I get a "cannot do this action blah, or do you wanna resend the form?". I don't want this to occur, but to simply go back to the page with my data I already hit into the form.

An example would be hitting preview in a forum and going back to edit it.

lorax

3:31 am on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You're dealing with two issues.

First is that once you click submit you've sent the form. The browsers are giving you those error messages because they were designed to look for duplicate submissions of the same form for security reasons.

Second is that you're using the browser's back button rather than providing the user a method to go back and make edits. Control the user's browsing by giving them a way to go back and make changes.

Option one is to enable sessions [us2.php.net], allow the user to edit and view thier form but do not send the form until the user has had a chance to review/edit it to their satisfaction. Sessions will allow you to carry the values of the form fields as the user bounces back and forth between the form and the review pages.

Alternately, if you don't want to get into sessions you could also just use hidden vars on the review page and pass them back and forth.

bobnew32

4:34 am on Dec 3, 2003 (gmt 0)

10+ Year Member



Well even with this forum software I can post this message, go back and resubmit. I don't think it uses sessions either.

bobnew32

4:35 am on Dec 3, 2003 (gmt 0)

10+ Year Member



Well even with this forum software I can post this message, go back and resubmit. I don't think it uses sessions either.

Ok never mind that didnt work, (can you delete messages). Well I can still hit the back button without it messing up, explain that?

lorax

2:46 pm on Dec 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> Well I can still hit the back button without it messing up, explain that?

Good question. I am not 100% sure about this but here is what I think is happening. The back button is client side. It's just showing you the last page you viewed. If it was a form then it will most likely show you the form as you had submitted it. Your form on your website must have some code that requires interaction with the server (perhaps and onLoad event?) so when you use the back button you are making another request to the server.

bobnew32

4:31 am on Dec 8, 2003 (gmt 0)

10+ Year Member



How would I have it not do that onload statement? I remember reading a php coder's toolbox article, and being able to do this was one of the top things most unknown but most usable. This is a top priority of mine, I really want it shut off for doing that in alot of the scripts i'm making. :( Plz help.

Damn, if I didnt redo my computer losing all those favorites.

EDIT: What about this?
session_cache_limiter('private, must-revalidate');

lorax

3:54 pm on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Perhaps we should start with what you're doing with the onLoad event.

bobnew32

9:44 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



Ok all, I actually found the solution! You can do "so called" forms if you use the php header function!

Heres what you do, I have a form that you user inputs ban information, after the form gets submitted, the code that checks the form gets all the input from the form, and instead makes a dynamic variable from it, and you get sent to it after its made.

Example, i'm on a ban page where its asking me for ban information. I enter it all in, hit submit, and get a header to this sample page which is what actually carries it out and gives me some nice text like "your ban was completed"

htt://site.com/?fn=ban&user_id=3&days=4&ppd=9&forum_wide=&forum_id=2

its ingenious. But what about long posts sadly, would they just enter the info in on the submit and the confirmation page is what you get the header to? You can hit back successfully in all of these conditions as well.

jamesa

9:54 am on Dec 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you give each page a unique file name (form1.php, form2.php) OR a unique query string (form.php?p=1, form.php?p=2), the browser will be able to cache them. Could even throw a random value in the query string if you want.