Pushing back causes 404 error on PHP page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Pushing back causes 404 error on PHP page

Post by Stryks »

Hi all,

I'm not really sure how or why this would happen, but I'm interested to sii if this is someone else has come across.

I have a page that shows different content based on the arguments passed, for example:

Code: Select all

mypage.php?view=2
So, my problem is that if I have a series of pages and the user gets part way through and then pushes back, I get a 404 page not found error even though the page is actually there. I can push refresh and the page reloads and everything, but I really dont want broken pages all over the place.

I dont know if it makes any difference, but the pages I notice it most contain forms, usually forming a chain of input.

Any ideas?

Thanks
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

you mean this happens in IE only right? (im assuming)

Code: Select all

<?php

header('Cache-Control: private, must-revalidate');

// or if using sessions, u can do this

session_cache_limiter('private, must-revalidate');

session_start();

?>
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

i reread this, and i misunderstood when i first replied. the above prob wont work.

are you using gzip on these pages? if so,
ie seems to have a bug with gzipped pages using forms. if your using POST, an easy solution
is to add a ? to the action of the form. dunno why it works but it does.

<form method="post" action="script.php?">
...
</form>
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Actually, its interesting that you post that, as I was wondering whether it was worth mentioning that the form is using POST, and the action is "signup.php?step=3".

Another thing that I really should have noticed earlier, is that its not actually a 404 error at all, but a DNS not found page. Its locally hosted and as I said, it refreshes if you push the browser button.

Perhaps I should find another way of passing the values between forms.

What I've got is a series of forms contained within a single php script, which calls the correct form depending on what stage you are at. After a form is submitted, it tests the input for validity and then either allows you to continue or brings back the previous form with the correct values filled in and the focus on the field that was incorrect.

Thats what breaks it I think. It seems that most of the time it works fine if the values are all valid and we move to the next form. We can push back and it goes back as expected ... well ... most times. Where it breaks pretty much every time is when the form fails validation. The form is posted, and the new URL is signup.php?step=2, but form 1 is shown again to allow valid input. Then you correct it and push submit, and you are taken to the same URL with step 2 showing. But if you push back there it breaks.

Funny thing is, I cant really fault the code. But I cant test it because as I said, it doesnt give errors, it just loads that stupid IE generic error page, citing DNS problems as the cause. (Why in the hell did they ditch the old identifyable pages. I also wish an incorrect URL didn't redirect to a search page and make me type the URL again, but hey, thats another thread on another forum.)

Just for interest sake, when the form values are validated, they are stored in session variables until the last form is filled in at which time it is inserted into various tables.

Does this help narrow down the issue, or am I just going about this all wrong. I'd post code but I'm at a loss as to what part might be causing a problem, if it even is a code problem.

Thanks.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

I also wish an incorrect URL didn't redirect to a search page and make me type the URL again
That's not IE, that's spyware.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

your not going about it the wrong way. IE is just...well you know lol

even google uses the ?page=3 method of filling out forms on multiple pages. its a good method. ie is just a bad browser lol

you know ive had the same problem, that dns error thing in ie. And it only happens sometimes. i cant find the pattern to it.

if i find it ill post back
Post Reply