SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Sault Ste. Marie
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry 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

    Form with GET
    http://www.blc-grmi.org/hill_child/contactGET.php

    Form with POST
    http://www.blc-grmi.org/hill_child/contactPOST.php

    Form as TXT
    http://www.blc-grmi.org/hill_child/contact.txt

    Validation Script (looks complicated but my boss likes comments)
    http://www.blc-grmi.org/hill_child/c...tionObject.txt

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GET produces QUERY STRINGS in the address bar of the browser, as you sure know. Hence, to the browser, your warnings-messages in GET are a NEW page.

    This ain't so with POST. The URL in the address bar is still the same, although the content is different. So, the browser CANNOT "go back". Browsers are stupid like that ;-)

    I suggest using only one method. I personally prefer POST. Why using two for the same thing?

    Try using SWITCH / CASE, they come in quite handy for form-checking. Or simply use "action=a_new_page.php" instead of PHP_SELF...

  3. #3
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Sault Ste. Marie
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks for replying.

    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.

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Very Bizzarro Form Submission Problem in IE

    Originally posted by searaig
    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.
    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

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I can tell, there's nothing "funky" in your val. class.

    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.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops... Larry's solution is 1000 times better / faster, hehe.

  7. #7
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Sault Ste. Marie
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now i'm just curious...

    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?

    What could this be?

  8. #8
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like i asked, is the page being gzipped on the problem server? and not on the others? i've only noticed the problem when the page is gzipped.

  9. #9
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Sault Ste. Marie
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't know what gzipping is, so i misunderstood, how can i find out? run PHPINFO() on the server?

  10. #10
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    GZIP is compressing the page via PHP's GZIP or via mod_gzip in Apache, etc. to see if a page is gzipped, you can test it here: http://leknor.com/code/gziped.php enter the address of your pages.

  11. #11
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Sault Ste. Marie
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your absolutely right. the solaris/apache doesn't gzip and the linux/apache does. weird.

  12. #12
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup, so that's the problem! same symptoms for me in IE. just make sure your action= attribute has at least a ? after the filename, and it should be fine.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •