Click to See Complete Forum and Search --> : submit two forms with one button
benracer
02-13-2008, 11:18 PM
hi,
how can i submit two forms with one button, one to send the order to me and the other to paypal? I need it to not contain javascript. I have this one so far but when customers have js disabled i get the payment but not the order contents.
onSubmit="document.forms['form_2'].submit();"
Weedpacket
02-14-2008, 12:24 AM
Have the script handling the form that was sent to you make the second form submission to paypal.
Not only does this not break the operating principles of http, but also means that you can control the contents of the form sent to paypal.
bradmasterx
02-15-2008, 04:56 AM
here's one i just did below
[code]
<form action="some_page.php" method="POST" target="_blank" name="form1">
</form>
<form action="some_page.html" method="GET" target="_blank" name="form2">
</form>
<script language="javascript">
function submitForms(){
document.form1.submit();
document.form1.submit();
}
</script>
<a href="#submit" onClick="submitForms();" id="submit">Submit</a>
[code]
Weedpacket
02-15-2008, 06:06 AM
here's one i just did belowNice; now factor in the requirement that it work without Javascript ;)
benracer
02-15-2008, 06:52 AM
Thanks for your effort, this seems to be not as rare as it looks. I have searched google for hours trying to find a compliant solution. At the moment i have just some no script tags with a message in to enable active scripting. From my view the type of customers i deal with mostly find it challenging to add an item to their cart let alone change browser settings. :)
The paypal form is..
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline" onSubmit="document.forms['form_2'].submit();">
<input type="hidden" name="cmd" value="_xclick" />
<input name="return" type="hidden" id="return" value="/cart/ordercompleted.php" />
<input type="hidden" name="business" value="sales@x.co.uk" />
<input type="hidden" name="item_name" value="Order #<?php echo $orderid; ?> " />
<input type="hidden" name="amount" value="<?php echo $total_price; ?>" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="no_shipping" value="2">
<input type="image" name="submit" src="/images/checkout.png" alt="Pay Now" />
</form>
Weedpacket
02-16-2008, 05:55 AM
Have the script handling the form that was sent to you make the second form submission to paypal.
Not only does this not break the operating principles of http, but also means that you can control the contents of the form sent to paypal.
benracer
02-16-2008, 07:02 AM
How can i send one form to two places, is this what you were suggesting weedpacket?
NogDog
02-16-2008, 07:35 AM
I believe what he is suggesting is to send the form to one PHP script, then use that PHP script to send the necessary form data to the external site via the cURL functions or similar methods. That script can also parse the data returned by the external site's response to that form submission allowing you to do whatever needs to be done at that point to continue processing the request.
rscott7706
04-15-2008, 11:30 AM
Hey all....
I have a similar need, but actually very different.
I am preparing an online registration for our local Chamber of commerce. It requires some maneuvering to get the results we want.
The initial form captures registration info (name, address, etc).
When completed, I would like it to give the user two payment choices:
1. Pay by check or money order.
2. Pay by PayPal
If the user chooses "Check or Money Order", the form immediately submits and user goes to "Thank You" page.
If the user chooses "PayPal", the info part of the form is submitted, and the user is redirected to a PayPal payment page.
Is this possible?
Thanks in advance!!
:)
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.