Need form sent to 2nd page and pass data after to outside website

I am writing the code for handling Paypal payments on my site. Paypal gives you the code to write their buttons, which store the necessary variables in “hidden” inputs, which then get sent to PayPal’s website for checkout when the order button is clicked.

In my case, I want my page to check a couple things before going to the Paypal site, so I have the form action instead go to a validation page, and then use PHP in the header to check the $_POST data. I can do that… I’m just not sure how to now get the data moved onto the Paypal website, since the $_POST variables are only good for one page transition. And of course, I can’t store the $_POST variables as session variables since those are only good within site (and even if they could transfer to Paypal, they are looking for $_POST variables on their page).

I was thinking at first that I could use PHP to write a new form on the 2nd page, and the new form would contain hidden inputs with all the data filled out from the $_POST, and then use the tag trick to bump the page onward to the correct Paypal URL… but that wouldn’t be using form submission and therefore none of those hidden inputs will get sent.

Is there a way to have a submit button trigger automatically when it is loaded? That would solve the problem, I think.

Lots of ways to automatically run a submit button.
You could use Javascript and have the first command press the button.

You can use this Javascript code to press a buttom…

<script>
document.forms["myform"].submit();   //Name I used for your button is "myform"  this is the ID of the button
</script>

NOTE: in a submit button, there is a NAME= and an ID= tag. You need to use the ID for use in javascript.

Hope this helps…

Thanks, that should do the trick. I’ll have to leave a message on the page that says that to use the coupons, you have to have javascript enabled. I realized after posting the original message that there couldn’t be a way to do it purely in PHP, since what I’m asking for is something that has to be client-side.

Yes, as far as I know there is no way of posting server-side. But, that should do it.
I will mark this thread solved…

Sponsor our Newsletter | Privacy Policy | Terms of Service