I've searched for this all morning and it seems like it can't be done with headers alone.
What I need to do is have a user fill out a form on my website:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<label for="qty">Quantity</label>
<select name="qty">
<?php
for($i=1;$i<=20;$i++){
echo '<option value="'.$i.'">'.$i.'</option>';
}
?>
</select>
<input type="submit" value="submit">
</form>
when it brings it back to the same page it makes sure the quantity selected is a real quantity (not negative, not alpha, all that fun stuff...).
After it's done with all that, I need it to redirect to PayPal for the person to pay:
$args = "cmd=_xclick&".
"business=me@gmail.com".
"&item_name=Tokens".
"&item_number=this_needs_to_be_replaced".
"&amount=5.00".
"&no_shipping=1".
"&undefined_quantity=".$_POST['qty'].
"&buyer_credit_promo_code=".
"&buyer_credit_product_category=".
"&buyer_credit_shipping_method=".
"&buyer_credit_user_address_change=".
"&no_shipping=1".
"&return=www.google.com".
"&no_note=1".
"¤cy_code=USD".
"&tax=0.00".
"&lc=US".
"&bn=PP-BuyNowBF";
Those are some of the hidden fields PayPal provides. I tried making each one a POST variable (i.e. $POST['cmd'] = "xclick"; etc.) and then send a redirect header, but it didn't work. Then I found a CURL tutorial:
$URL="https://www.paypal.com/cgi-bin/webscr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
curl_exec ($ch);
curl_close ($ch);
but it seems like that only grabs the contents of the page rather than redirecting. I've never used CURL before, but I figured I'd might as well post this while I mess around with it in the meantime.
Any ideas?
Thanks
Steve