Hey Hii ....
I am solving this problem from last 2 days....
but unable to find solution.
What i am doing is .....
On click of submit button i want to send email and i am taking client to paypal page to do the payment.....
i. e. i want to send FORM data to two different pages.

document.form.action = 'xyz.com/order/email_order.php';				
document.form.submit();
					
document.form.action = 'https://www.paypal.com/cgi-bin/webscr';
document.form.submit();

Its working fine in Mozilla but not in other browsers.....
Or Is there any other solution??
....i dont want 2 submit button.

when you hit submitt you can have a variable that gets submitted in like php which will post to the page then in the top make a if statement so that if first option is met do this and so forth i think same concept applies to javascript also

If you would like it to post on server side then you could just use curl. So the following is an example script that will display only the paypal page but still submit the post variables to the second link:

$vars='';
foreach ($_POST AS $key => $val) {
$vars.=$key.'='.$val.'&';
}
$vars=substr($vars,0,-1);
$ch = curl_init();
// set the target url
curl_setopt($ch, CURLOPT_URL,'xyz.com/order/email_order.php');
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$dresult= curl_exec ($ch);
curl_close ($ch);

//now for paypal
$ch = curl_init();
// set the target url
curl_setopt($ch, CURLOPT_URL,'https://www.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec ($ch);
curl_close ($ch);
echo $result;

So if you post to a page that has just the above script, the above script will then re-post the data to the 2 links provided.

or you can do a fopen HTTP POST from the email_order.php

$fp = fsockopen($host, 80);
 
// send headers
fputs($fp, "POST /cgi-bin/webscr HTTP/1.1\r\n");
fputs($fp, "Host: https://www.paypal.com/ \r\n");
fputs($fp, "Referer: www.yourdomain.com \r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($data) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);

// get the output
$result = ''; 
while(!feof($fp)) {
        $result .= fgets($fp, 128);
    }
 
// close the socket connection:
fclose($fp);

although i'm not sure if paypal security will prevent that.

... i. e. i want to send FORM data to two different pages.

document.form.action = 'xyz.com/order/email_order.php';				
document.form.submit();
					
document.form.action = 'https://www.paypal.com/cgi-bin/webscr';
document.form.submit();

Its working fine in Mozilla but not in other browsers.....
Or Is there any other solution??
....i dont want 2 submit button.

You should go to PayPal's dev site and see how to do it properly. They have a method by which your site receives the form data, processes it, then sends the user off to PayPal with a transaction reference (actually, your return URL with a reference) and other info. When PayPal finishes processing the payment, it will direct the user back to your site with your reference and its transaction info so you can finish logging the payment in your database and complete the sale.

I did this with a real hokie merchandise sales site some years back; it worked well. It worked even better after I eventually converted to OS Commerce; it was all integrated into the database.

Hey Guys...
Thanx for ur valuable time.....
I solved this Problem....
.
.
.
What i did is....
I redirect the user to page from which i m sending an email.
And from there i send required fields to Paypal.com
Mail sending page doesnt shown any O/P.....There i executed the function to send mail.....and redirected user to Paypal.com with reqired fields.

Thanx Once again....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.