So I've done quite a few forms before but I'm running into trouble with this one. I'm not exactly sure what I need to do, but let me explain.
I have:
Form A
Form B
Form A collects basic data from a customer. Form B give you the option to select two products (Pay Pal). Depending on what product you pick, the last field on Form A will populate with that value, which was blank before.
I chose to do it this way because my type of Pay Pal account couldn't handle multiple custom fields. I also needed to know which customers data corresponds to what package they ordered and not have to figure it out through Pay Pal incase the e-mail they enter is different for whatever reason. What I need is when the "buy now" button is clicked, the php action for form A to run and for the customer to be redirected to Pay Pal to pay.
I've tried it several ways but nothing is working, the form info is not coming through to my e-mail - it only brings the customer to Pay Pal. I was thinking to have two actions on the Pay Pal form, but something doesn't make sense to me with that. I tried some jQuery to make the form submit without refreshing or redirecting but that didn't work. I really need both actions to be triggered as the absolute last thing they do. For example if the customer selects the higher priced package, and hits submit on the first form, they can go back select the lower level package and pay for that. Granted I would probably catch it, but it just seems like a headache to me.
Here's part of what I'm working with:
<script tyle="text/javascript">
$(document).ready(function(){
$form = $('citationinfo');
$form.submit(function(){
$.post($(this).attr('citations.php'), $(this).serialize(), function(response){
// do something here on success
},'json');
return false;
});
});
</script>
<script type="text/javascript">
function setPrice(selObj){
document.forms['citationinfo'].price.value = selObj.options[selObj.options.selectedIndex].value;
}
</script>
<form id="citationinfo" name="citationinfo" method="post" action="citations.php">
<br>*14 fields of basic info to fill out*<br />
<label>Citation Pack:</label>
<input name="price" type="text" class="form" id="price" size="50" readonly="readonly"/>
<br />
<span class="style6">(Select below on Citation Options) </span><br />
</form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit"document.citationinfo.submit()">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
and my php
<?php
$emailSubject = 'Citation';
$webMaster = 'myemail@mydomain.com';
$price = $_POST['price'];
$body = <<<EOD
Citation:<br>
Package: $price<br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
$theResults = <<<EOD
EOD;
echo "$theResults";
?>
Sorry I couldn't post everything. There's not really one thing I'm trying to "fix" I've just been working with a whole bunch of different pieces and moving everything around. Let me know if you have any suggestions.
-Mel