"Mimic" a form-submission with post params

Dear all,

I’m developing a web shop for a client. Some payment within that shop is handled via a third party. In order to connect to the payment-site the user has to submit a form with post data to a HTTPS location. This form contains hidden fields with all the payment details. After payment is done, the payment module will redirect to any url I specify. So in order for the users to enter that external payment site, they have to press a submit button. This is not what I want. The shop is offering multiple payment methods, so if one is selected I want the user/customer directly to be redirected to the correct page without him/her having to push another payment button.

So my thought is to have PHP “mimic” a submission form. I have gotten as far as using cURL. All works fine but the problem is that there is no real redirection taking place. The post data is being submitted fine, but instead of the user being directed to that location, the output of cURL session is being dumped in my script file. When displaying this in a web browser, this gives problems with relative paths to links and images. Adding a tag in the tag could probably tackle that issue, but I feel that this isn’t a very elegant solution.

There is also the possibility of letting javascript submit that form on onload. Again, not very elegant in my opinion.

My question is, is there a way to let PHP the user go to an url with post params as if that user was submitting a form and directed to the location defined in the ‘action’ parameter.

Maybe with header/location/content-type statements?

Thanx in advance!

Sponsor our Newsletter | Privacy Policy | Terms of Service