My form action sends hidden inputs to PayPal for checkout. I also need it to send me an email before it goes to paypal.
But since the action of my form calls paypal I cant trigger the other function. I was thinking I could just have the action=self and do what I need on my page and then send the nessesery post variables to paypal. I am taking a shot at it below:
<?
if(isset($_POST['submit'])){
//get post data for me clean up and save then send
if(!mail(data, myemail, headers)){
//send data to paypal.
curl(https://www.paypal.com/cgi-bin/webscr);
}
}else{
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- DATA FOR ME-->
<p>Child's Name: <? echo $child_name; ?></p>
<input type="hidden" name="child_name" value="<? echo $child_name; ?>">
<p>Birth Date: <? echo $birth_date; ?></p>
<input type="hidden" name="birth_date" value="<? echo $birth_date; ?>">
<p>Parent/Guardian Name: <? echo $name; ?></p>
<input type="hidden" name="name" value="<? echo $name; ?>">
<p>Email Address: <? echo $email; ?></p>
<input type="hidden" name="email" value="<? echo $email; ?>">
<p>Home Phone: <? echo $phone; ?></p>
<input type="hidden" name="phone" value="<? echo $phone; ?>">
<!-- DATA FOR PAYPAL-->
<input type="hidden" name="business" value="you@youremail.com">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXX">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
</form>
Should I use curl to resend the data to PayPal once the mail() function on my page was successful? Not sure how that will work?
May be like this