[thelist] POST data with PHP

Richard Livsey richard at livsey.org
Wed Aug 11 20:52:46 CDT 2004


A tricky one this, and I'm not sure if it is at all possible, but here goes.

1. I have a form which points to a PHP script.
2. When the script receives the POST data, it validates it.
3. If the data doesnt validate, a page is displayed with details.
4. If the data validates, then the POST data wants to be sent on to 
another page which may not be on the same server.

Is step 4 possible?

Ie say we have a form which wants to submit to google. Usually you would 
just set the action of the form to be http://www.google.com (or whatever).
But what I want to do is basically have an intermediate step which will 
first validate the data which is about to be sent and then only send the 
POST data on if all is ok.
So if the data validates, the user is unaware there was even an 
intermediate script being called. They end up at google as if the action 
was set to it.

Snoopy or cURL would usually be what I'd look at here, but I want the 
browser to go to the page, not just submit the data.

One way I've got working is to generate a form and then submit it with 
javascript on load. If the user doesnt have JS then there is a submit 
button.
However, ideally I want to skip this bit and just have the system 
seamlessly submit the data on.

I've looked at sending 30x headers and then redirecting with a Location 
header, but as far as I can see from the specs these will/do not re-send 
the POST data.
Another alternative is to send the data on in the query string. But due 
to the size of some of the forms this is out of the question (plus the 
sites expect the data as a POST request).

Any ideas, or am I stuck with the intermediate page and javascript?

Thanks in advance.

-- 
R.Livsey
Incutio Web Developer
www.livsey.org
www.incutio.com


More information about the thelist mailing list