Paypal IPN blues... in php
So now that I have the intro set here is the url for the Recipes site.
Here is the php code for the ipn.php file.
<?php
session_start();
include 'inc/connect.inc';
$name=$_POST['first_name'].' '.$_POST['last_name'];
$email = $_POST['payer_email'];
$phone = $_POST['contact_phone'];
$table="users";
$msg="<HTML><BODY>";
$msg.="Hello,<br />";
$msg.='Your name: '.$name.'<br />';
$msg.='Email: '.$email.'<br />';
$msg.='Phone #: '.$phone.'<br />';
$msg.="<br />";
$msg.='Username: '.$_POST['custom'].'<br />';
$msg.='Password: '.$_POST['pass'].'<br />';
$msg.='Password Hint: '.$_POST['passhint'].'<br />';
$msg.='Password Answer: '.$_POST['passanswer'].'<br /></BODY></HTML>';
$headers="From: Your From Name Here <jason@bitsonline.us>\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-type: text/html; charset=iso-8859-1";
$to = 'jason@bitsonline.us';
$subject = 'Recipe Area | Invalid Payment';
$message = '
Dear Administrator,
A payment has been made but is flagged as INVALID.
Please verify the payment manualy and contact the buyer.
Buyer Email: '.$email.'
';
$headers1 = 'From:jason@bitsonline.us' . "\r\n";
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr);
if (!$fp) {
// HTTP ERROR
echo "Error processing your request. Please try again later.";
exit();
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
$q1="update $table set name='$name',email='$email',phone='$phone',status='approved' where user='$_SESSION[user]')";
$res=mysql_query($q1) or die("Error updating user information: ".mysql_error());
if(!empty($q) && isset($res)){
$mailsent=mail("jason@bitsonline.us,$email","New user registration",$msg,$headers);
echo $mailsent ? "Registration complete. Check your email in a few minutes for more details.<br /><a href=recipes.php>Log In</a>" : "Registration failed. <a href=recipes.php>Go Back</a>";
exit();
// PAYMENT VALIDATED & VERIFIED!
}
if (strcmp ($res, "INVALID") == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
mail($to, $subject, $message, $headers1);
}
}
}
}
fclose ($fp);
?>
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Join the next generation affiliate marketplace today
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin
Do you want to make successes or excuses? Success? Alright then... See what's in store for you....
- The AC Assassin