Jump to content

Form to email then to Paypal php script


TomUgro

Recommended Posts

Hello everyone at phpfreaks!

 

I'm hoping someone can help.  This is a scipt that was written to take an html form, email it to someone and then using javascript send the information to Paypal for processing. 

 

I don't understand php or javascript very well and am really hoping some genius can help me.  When I try to run this on my server I first get php syntax errors.  Then if I get that worked out the javascript simply doesn't work.  There is no redirect. The email feature is working fine though.  :confused: (btw, I'd love to post as well in the Paypal forums but they don't seen to bloody work for me  :( )

 

Here is the code for the form

<html> 
<head> 

<meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 

<title>PayPalTech.com - Send email and Redirect to PayPal example</title> 
<script language=javascript> function ReadForm (obj1){ 

//I added this function so that you can see how the information is passed in the button code 
//to PayPal and listed in the transaction details as well as email out the information. 
//You could do this in the script you send the information to. 

var day= example.day.options[example.day.selectedIndex].value; 
var month = example.month.options[example.month.selectedIndex].value; 
var year = example.year.options[example.year.selectedIndex].value; 
example.holder.value = "Name ="+ example.name.value + " Phone: " + example.phone.value + "Date:" + day + "/" + month+ "/" + year; 
}//end of readform 
</script> 

</head> 
<body> 
<fieldset> 
<form method="POST" action="formproc_to_paypal.php" target="_blank" onsubmit="ReadForm(this);" name="example"> <input type="hidden" name="holder"> <p>name 
<input type="text" name="name" size="20" value="test tester"></p> 
<p>phone 
<input type="text" name="phone" size="20" value="555-555-5555"></p> 
<p>day
<select size="1" name="day"> 
<option value="1">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
</select> 
mo 
<select size="1" name="month"> 
<option value="1">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
<option value="4">4</option> 
</select> 
yr
<select size="1" name="year"> 
<option value="2007">2007</option> 
<option value="2008">2008</option> 
<option value="2009">2009</option> 
</select></p> 
Color: <input type="radio" name="mycolor" value="red"> red 
<input type="radio" name="mycolor" value="blue">blue 
<input type="radio" name="mycolor" value="green"> green 
<input type="radio" name="mycolor" value="black">black 
<input type="radio" name="mycolor" value="grey"> grey <br><br> Types: 
<input type="checkbox" name="size1" value="overnight">Overnight Delivery <p> </p> <p>
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> 
</form> 
</fieldset> 
</body> 
</html>

 

 

And here is the code for the php script.

 

<?php 

//set the email address here. 
//example 
//$email = "[email protected]"; 

$email = "[email protected]"; 

//set the email subject line here. 
//example 
//$subject = "Order"; 

$subject = "Order"; 

// next, loop through the $_POST array, set $message = to the values of the array and a newline for formatting. 

foreach($_POST as $key => $value) { $message .= $value."\n"; } 

//send the email 

mail($email, $subject, $message); $os0 = $_POST['holder']; –> 

//now, create a webpage page and dynamically submit the PayPal form with Javascript --> 

<html>
<head> 

<script language="JavaScript" type="text/javascript"> 
<!-- 
function submitForm() { 
document.myForm.submit(); 
setTimeout('self.close();',10000); 
} 
//--> 
</script> 
</head> 

<body onLoad="javascript&colon;submitForm()"> 
You are being redirected to PayPal. This window will close itself in 10 seconds. 

<form name="myForm" method="post" action="https://www.paypal.com/cgi-bin/webscr" target="_blank"> 
<input type="hidden" name="business" value="[email protected]"> 
<input type="hidden" name="cmd" value="_xclick"> 
<input type="hidden" name="item_name" value="test"> 
<input type="hidden" name="amount" value="12.00"> 
<input type="hidden" name="on0" value="Variables"> 
<input type="hidden" name="os0" value="<? echo $os0 ?>"> 
<!--pass along the information collected --> 
</form> 
</body> 
</html> 
</xmp> 
</fieldset> 
<p></p>

Link to comment
https://forums.phpfreaks.com/topic/180878-form-to-email-then-to-paypal-php-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.