The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Very Bizzarro Form Submission Problem in IE

I have a script that validates a fairly simple form which spills out errors and asks the user to hit the back button to correct the errors.

Problem is that in IE6 the error page is sent twice to the browser with POST but not with GET method.

When the error page is sent twice it seems to flush the form down the drain if you hit the back button. But, if you hit the refresh button while on the error page, the original form is displayed. WTF? (the whole thing works fine in Netscape--for once).

One last weird thing (for me, maybe obvious to someone else) is that if you add a "?" to the script with POST the error disappears.

Please, if you can help me out. I really need this script/browser problem sorted out

I don't actually use 2 different scripts i just wanted to illustrate the problem as clearly as possible. I almost always use POST as well except for debugging.

Could you take a look at the Validation Class and see if there's anything funky in there. I'd really appreciate it. It's quite a powerful script--it allows me to validate ANY form using regexp in only a few lines and send custom feedback messages in a couple of different ways. saves a lot of time and i don't want to trash it yet b/c i hate writing a whole tonne of form validation code all the time.

Re: Very Bizzarro Form Submission Problem in IE

Originally posted by searaigOne last weird thing (for me, maybe obvious to someone else) is that if you add a "?" to the script with POST the error disappears.

aha! this is a browser problem i think with IE (the way it handles gzipped pages). is the page being gzipped (through PHP or mod_gzip)? this happens for me too when using POSTed forms without a query-string (hence why adding a "?" fixes it). click on the Advanced Search at the top of these forums, do a search, and then try to get back to the search from; won't happen. you'll just the the "being taken to results page" and have to reload to get the form again.

so it sounds like this is the problem. to fix it, i just put a "?" in the action= attribute of the form (e.g. action="file.php?"). i guess you'll have to do the same.

- Matt ** Ignore old signature for now... **
Dr.BB - Highly optimized to be 2-3x faster than the "Big 3." "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

The easiest thing to try though is simply using my advice given above:

page 1: the form

on submit --> go to a "control"-page = page 2
page 2 checks all fields, and displays warnings if necessary. If everything is nice and dandy it processes the email/db-query etc. and redirects to a "thank you page".

Another approach:

beneath or next to every form field, include
<? echo "<br><b>" . $fieldName_ErrorMsg . "</b><br>";?>

If the page is first loaded, these vars are empty, so nothing is displayed to the user. If the user presses submit (action=self), these vars are given values if errors exist. This is a nice approach and user-friendly, since the user knows exactly WHERE the missing fields are, no browser-back-button needed.

The same can be also achieved with Javascript btw, but of course it's safer to do it all in PHP (server-side).

Still another way would be a pop-up window. This would either display a "thank you $username" message, or errors.

The workaround is simple enough but it might be more complicated than that b/c today i tried the script on 4 servers--2 NT a Solaris/Apache and a Linux/Apache and the script works fine on all except the Linux/Apache?