SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Form submit gets redirected

    Hi guys,

    First of all, I wanted to post this under a much more defined category, but this is as relative as I could find.

    I have this form that when submitted sometimes automatically redirects to 404. This form has only 2 fields, a title and the article body. The form defaults to application/x-www-form-urlencoded. The log below is taken directly from Live HTTP Headers.

    Code:
    http://www.faulty-domain.com/article-page
    
    POST /article-page HTTP/1.1
    Host: www.faulty-domain.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23 ( .NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 115
    Connection: keep-alive
    Referer: http://www.faulty-domain.com/article-page
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 3288
    blog_title=Article+Title+to+save&newsbody=%3Cp%3EThe+current+blah+blah+blah%3C%2Fp%3E
    
    
    HTTP/1.1 302 Found
    Date: Tue, 08 Nov 2011 12:42:23 GMT
    Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.14
    X-Powered-By: PHP/5.2.14
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Location: http://www.faulty-domain.com/notFound
    Content-Encoding: gzip
    Vary: Accept-Encoding
    Content-Length: 26
    Connection: close
    Content-Type: text/html
    As seen above, the page sends to itself, then is suppose to check if the method was post, the usual stuff. But then the http response is a notFound page. Clearly the web server did not even executed our index.php, but decided based on the request headers somehow that the response should be a 404.

    Now I've done my own debugging, and played with the article I'm sending. I tried to append the article paragraph by paragraph and see on what paragraph the bug triggers. The form submits fine until a certain paragraph, at that point I said Bingo! I thought I isolated the problem and tried to submit the form using that paragraph alone, but then the form submitted. Which now puzzles me, why would apache accept it as it is, but if appended on the end of the original article, it goes nuts!

    Anyone's got any idea? It's probably an htaccess thing, or a web server thing, but I just couldnt get this thing nailed. Any form of help is much appreciated!
    Last edited by lance_vincent; Nov 8, 2011 at 07:50. Reason: edited blog_title field just to make things simple
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post the code for your form as well as your form processor? That might help us to better help you.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you tell us what the action attribute of the form is as well as the method?
    Or, provide a link to the form in question?

    Regards,
    Michael

  4. #4
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry guys for the delayed response.

    The form on the html page looks something like this

    Code:
    <form name="editArticleForm" method="POST" action="write-article">
    on the form processor (which is also the same page), it looks like this

    Code:
    if($_SERVER['REQUEST_METHOD'] == "POST"){
    $article = array("blog_title"  => $_POST['blog_title'],
    		"blog_text"   => $_POST['blog_text']);
    $db->AutoExecute("blog",$article ,"INSERT");
    }
    The million dollar clue here is that the entry point of our framework, index.php, does not get executed when I submit the form, as seen on the headers information above.

    I spent most on my time trying to look into possible htaccess issues here, but what we try to handle there are url patterns. Any other guesses?
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.


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
  •