permutations
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by permutations
-
-
I have a CGI script written in C that processes data posted to it. It then redirects to a page known by the CGI script, but not to the form that submits to it (the CGI figures out the result location).
When I post to the CGI script using an HTML form, it works correctly. The problem comes when, instead of posting to the CGI, I post to an error-checking script written in PHP. When the data has been validated, I use a PHP script to post the data to the CGI. This should be the same as posting to the CGI from a form, but it's not.
When I post to the CGI program using a PHP script instead of an HTML form, I get an intermediate page which, instead of transparently redirecting, says: "302 Found: The document has moved here" where "here" is a link to where it should have automatically redirected. The user is forced to click, which I do not want.
Can someone enlighten me as to why the "Location" header works correctly when a form posts to the CGI, but not when a PHP script posts to it?? Any insight you can give me would be greatly appreciated!!
Alternatively, I could find a way to communicate back to my PHP script the result code the CGI generates and do the redirect there, but I can't figure out how to do that, either.
-
Did you find the solution to this? It's driving me crazy, too.
How to avoid intermediate page "The document has moved here."
in PHP Coding Help
Posted
I wrote to the author of CURL with this question, since he clearly knows the answer. He quickly sent me back a reply of very little help because I don't understand it. He just referred me to the section of RFC2616 on 302 redirects. It says this:
That's lovely and I'm sure it's helpful to someone, but it may as well be written in Chinese, for all the good it does me.
This is as much as I can glean: If you get to the URI via a POST request, then you must redirect via GET or you'll get the dreaded intermediate page. I'd be happy to do this if I had the slightest clue HOW. I've found this same advice in several places, but no one gives a code example.
I post to my CGI and I redirect with this statement:
What should I use instead??