You are invited to Log in or Register a free Frihost Account!

'POST' and redirects

If a form which is submitted using 'POST' gets redirected by the server (ie. if the server replies with the Location header), does the information in the post get resubmitted by the browser too.

Basically, I want to be able to verify and keep a copy of the data that my client is submitting, before forwarding them to a third party website (in this case, I'm making a checkout and redirecting to paypal). Will that work, or do I need to go about it in another way?

Im not totally sure what you mean but when you make a form and its method is post that information in the form will be lost if you have a redirect in the page that the form points to. Sessions could keep the data for you if you want or even $_GET[] possibly.
What you are exactly after is not possible in that sense.

It is possible to transmit POST data to another PHP script. However, it is not possible (to my knowledge) to send that data WITH a redirect.

In other words, you can send any/all post data to another script. So that part is true. You can send the user to another script. That part is true. However, you cannot send the user to another script with that data.

If it is adequate for your purposes, you may send the data to the new script, then send the user there. That much is simple enough.

If that would be good enough, reply here and I will show you how to go about doing it.
Look into sockets.
In the above page, they provide a post_it function.

Could also echo back an HTML <form> and force the user to click the submit button if the user has JavaScript disabled.

As bladesage stated, "Location:" forces a GET request.

In any case, I think you are approaching the Paypal thing wrongly and possibly misunderstand the system which they provide.
When your user is forwarded to the paypal page to make a payment to you, you can provide a notifying URL on that page which PayPal will POST to when the payment is complete. Usually you'd name it paypal.php and then you'd log the user info POSTed from paypal (first check the IP address to make sure it was indeed paypal rather than someone that posted to your notifying URL) into your database then anything your notifying URL echos is passed to the user which just submitted a payment.

I think you should read up some more on paypal.
Thanks for the feedback!

Actually, with PayPal, it was the start of the transaction I wanted to streamline, rather than the end. Basically, I'm using a custom cart, so I need to collect a lot of information before I can send the user to PayPal. So the user has to enter his details and then confirm his order on my site. Then, he'll need to click on the 'Proceed to Payment' button and go through PayPal's half-a-dozen screens to pay. I was worried this would be too much clicking from page to page for even simple transactions - which can get annoying. I was hoping I'd be able to make the 'Confirm' and 'Proceed to Payment' the same button (by redirecting the POST to PayPal). Not a huge issue, really. Just had me thinking.
Related topics
Where should I post a request?
post nuke problem
an't install post nuke
How post picture in the forum?
Post nuke
I wont be able to post for sometime
Callout: Post your ride(s)
UT2004 U like the game? Do u have any question post here.
post the funny movie at where?
Post here for what u think the Nintendo Revolution controler
admin ,i see somebody's post points less than -10.00,but ...
Is there any way to submit post data with php?
Automaticly Submit Post Data. 20 fri$ up for grabs.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.