PayPal IPN doesn't work with PHP5

software development

#1

My server was recently upgraded to a new 64bit server etc. My one site was still PHP4 and it is now (I believe) PHP5.

Now my PHP IPN script doesn’t work. I looked at the log and no vars seem to be getting passed. I just get /nipn and the date.

I read that I might need to turn registered globals on. Is that true?

The script has this line, which I believe should grab all the vars sent to the script.

[php]$req = ‘cmd=_notify-validate’;

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= “&$key=$value”;
}[/php]

Right now, I have a handful of subscribers that have no access to the site and I had to take down my subscription page.

Please help!


#2

That looks like it’s building up a “$req” variable, but isn’t actually setting anything else in your script. I understand that posting all of your code might be problematic, but can you post a little bit more context beyond this part?


#3

Okay, I think I managed to take out any sensitive information. This script has been working for over 6 years. It’s a bit long as it does a couple things for the site other than just add subscribers. But I think the primary issue is that the var are not going through.

Thanks for any help you can give.

[php]<?php

//------------------------------------------------------------------
// Open log file, Generate Date
//-------------------------------------------------------------------
$log = fopen(“ipn.log”, “a”);
fwrite($log, “\n\nipn - " . gmstrftime (”%b %d %Y %H:%M:%S", time()) . “\n”);

//---------------------------------------------
// Functions
//--------------------------------------------

//Open DB Connection

function connect_db() {
mysql_connect(“", “*******”, "") or die (“Problem connecting to Database”);
mysql_select_db("
***”) or die (“Problem selecting database”);
}

//Open DB connection
connect_db();

// Generate Random Password

function makeRandomPassword() {
$salt = “abchefghjkmnpqrstuvwxyz0123456789”;
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
};
return $pass;
}

// Check for duplicate txn_id

function checkDuptxn($dup_id) {
$result=mysql_query(“SELECT * FROM accounting_paypal WHERE txn_id=’$dup_id’”);

if(mysql_num_rows($result)>0) 	{ 
  // There's a dup
  return "false";
} else { 
 // Good to go
 return "true";
}; 

}

// Check for duplicate subscriber id

function checkDupSubID($dup_id) {
$result=mysql_query(“SELECT * FROM accounting_paypal WHERE subscr_id=’$dup_id’”);

if(mysql_num_rows($result)>0) { 
  // There's a dup
  return "false";
} else { 
 // Good to go
 return "true";
}; 

}

// Check for duplicate payer id

function checkDupID($dup_id) {
$result=mysql_query(“SELECT * FROM accounting_paypal WHERE payer_id=’$dup_id’”);

if(mysql_num_rows($result)>0) { 
  // There's a dup
  return "false";
} else { 
 // Good to go
 return "true";
}; 

}

// Check for existing password

function checkPassword($user_id) {
$sql = “SELECT password FROM users WHERE payer_id=’$user_id’”;
$result = mysql_query($sql) or die (“Couldn’t get results [1].”);
$row = mysql_fetch_array($result);
$pass_test = $row[“password”];
if (empty($pass_test) || !IsSet($pass_test)) {
return “false”; //There is no password
} else {
return “true”;
};
}

// Check for existing txn

function checktxn($user_id) {
$sql = “SELECT txn_id FROM accounting_paypal WHERE subscr_id=’$user_id’”;
$result = mysql_query($sql) or die (“Couldn’t get results [1].”);
$row = mysql_fetch_array($result);
$txn_test = $row[“txn_id”];
if (empty($txn_test) || !IsSet($txn_test)) {
return “false”; //There is no txn_id
} else {
return “true”;
};
}

function checkPaidTime($paid_for,$paid_time,$user_id) {
$sql = “SELECT $paid_for FROM users WHERE payer_id=’$user_id’”;
$result = mysql_query($sql) or die (“Couldn’t get results [1].”);
$row = mysql_fetch_array($result);
$old_time = $row["$paid_for"];
if ($old_time == 0 || $old_time == $paid_time) {
return “false”; //This is just an update
} elseif ($old_time > 0 && $old_time != $paid_time) {
return “true”; // This is a subscription change
};
}

function checkPaidFor($paid_for,$user_id) {
$sql = “SELECT $paid_for FROM users WHERE payer_id=’$user_id’”;
$result = mysql_query($sql) or die (“Couldn’t get results [1].”);
$row = mysql_fetch_array($result);
$old_for = $row["$paid_for"];
if ($old_for > 0) {
return “false”; //They are subscribed to this already
} elseif ($old_for == 0) {
return “true”; // They are not subscribed to this
};
}

function getCurrentCustom($paid_for,$user_id) {
$sql = “SELECT c_$paid_for FROM users WHERE payer_id=’$user_id’”;
$result = mysql_query($sql) or die (“Couldn’t get results [1].”);
$row = mysql_fetch_array($result);
return $row[“c_$paid_for”];
}

function sendemail($type,$email,$password) {

switch ($type) {
case “password”:
$message .= “Dear Customer,
\nThank you for subscribing to…
\nBelow is your username and password for the subscription you ordered. You should keep this in a safe place or change it to something you will remember easier by logging onto…
\n Username: $email\nPassword: $password
\nIf you have any problems, please contact us at:…Please enjoy your stay.
\nRegards,\n-…”;

mail($email, "Your ..... Subscription", $message, "From: info@.....com\nReply-To: info@.....com");
break;

case "payment":
$message .= "Dear Customer,
\nThank you for your subscription payment to.... We appreciate your business.
\nRegards,\n-....\n..... Publisher\n......com";

mail($email, "Your ...... Subscription", $message, "From: info@......com\nReply-To: info@......com");
break;

case "subscription":
$message .= "Dear Customer,
\nThank you for your subscription to .......com. We appreciate your business.
\nYour Username and Password will be emailed to you as soon as your payment has been processed.
\nIf you have any questions please contact us at: http://www.......com/contact.php
\nRegards,\n-.....\n......\n.......";

mail($email, "Your ........Subscription", $message, "From: info@......com\nReply-To: info@.......com");
break;

case "pending":
$message .= "Dear Customer,
\nThank you for your subscription to .....com. Your subscription is currently pending and will be made active when your funds have cleared.
\nIf you have any questions please contact us at: ......
\nRegards,\n-......\n.........\n........com";

mail($email, "...... Subscription - Pending", $message, "From: info@........com\nReply-To: info@.......com");

mail("subscriptions@........com", "...... Subscription - Pending", "An incomplete transaction requires your attention for $email.");
break;

case "cancel":
$message .= "Dear Customer,
\nYour ........ Subscription has reached its end of term. Your account has been closed.
\nIf you would like to give feedback or reasons for your cancellation please email us at: http://www.......com/contact.php
\nWe hope you enjoyed your time at ......
\nRegards,\n-....\n....\nwww........com";

mail($email, "...... Subscription - Cancelation", $message, "From: info@.....com\nReply-To: info@.....com");

mail("subscriptions@.........com", "..... Subscription - Cancelation", "$email canceled thier subscription.");
break;

case "unverified":
mail($email, "An Error Occurred...", "Dear Customer,\nAn error occurred while PayPal was processing your order. It will be investigated by a human at the earliest opportunity.\n\nWe apologise for any inconvenience.\n\nRegards,\n-......\n......\nwww.......com", "From: info@......com\nReply-To: info@.......com");

mail("subscriptions@.....com", "...... Subscription - Invalid", "An invalid transaction requires your attention for $email.");
break;
};

}

function referral($content,$switch) {
switch ($switch) {
case “add”:
mysql_query (“UPDATE Trans_contentTotals SET referral=referral + 1 WHERE content = $content”);
break;

	case "delete":
		mysql_query ("UPDATE Trans_contentTotals SET referral=referral - 1 WHERE content = $content");
	break;
};

}

//------------------------------------------------
// Read post from PayPal system and create reply
// starting with: ‘cmd=_notify-validate’…
// then repeating all values sent - VALIDATION.
//------------------------------------------------
//$postvars = array();
//while (list ($key, $value) = each ($HTTP_POST_VARS)) {
//$postvars[] = $key;
//}
//$req = ‘cmd=_notify-validate’;
//for ($var = 0; $var < count ($postvars); $var++) {
//$postvar_key = $postvars[$var];
//$postvar_value = $$postvars[$var];
//$req .= “&” . $postvar_key . “=” . urlencode ($postvar_value);
//}

// 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”;
}

//--------------------------------------------
// Create message to post back to PayPal…
// Open a socket to the PayPal server…
//--------------------------------------------
$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, 30);

//---------------------------------------------
// Write Transaction setales to the log file for backup.
//--------------------------------------------
fwrite($log, “Vals: “. $txn_type .” “. $receiver_email .” “. $first_name.” “. $last_name.” “. $payer_email.” “. $payment_date.” “. $txn_id.” “. $subscr_id.” “. $item_name.” “.$item_number.” “.$custom.” “.$payment_status.” “. $panding_reason.” “. $payer_id.” “. $payment_fee.” “. $payment_gross.” “. $address_street.” “. $address_city.” “. $address_state.” “.$address_zip.” “. $address_country.” “. $payment_type.”\ n”);

//----------------------------------------------------------------------
// Check HTTP connection made to PayPal OK, If not, print an error msg
//----------------------------------------------------------------------
if (!$fp) {
echo “$errstr ($errno)”;
fwrite($log, “Failed to open HTTP connection!”);
$res = “FAILED”;
} else {
// If connected OK, write the posted values back, then…
fputs ($fp, $header . $req);
// …read the results of the verification…
// If VERIFIED = continue to process the TX…
//-------------------------------------------
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, “VERIFIED”) == 0) {

		// If the payment_status=Completed... Generate a Password
		if ($receiver_email == "order@*****.com") {
			
				switch ($txn_type) {

					case "subscr_signup":		
						//Check for duplicates payer_id
						$dup_uid = checkDupID($payer_id);
			
						if ($dup_uid == "false") {
							//The User Exists already
							//Check for duplicate subscr_id
							$dup_sid = checkDupSubID($subscr_id);
							if($dup_sid == "false") {
								//This subscription aready exist
								//We only need to update the subscription then.
									mysql_query ("UPDATE accounting_paypal 
																	SET
																	subscr_date = '$subscr_date',
																	period1 = '$period1',
																	period2 = '$period2',
																	period3 = '$period3',
																	amount1 = '$amount1',
																	amount2 = '$amount2',
																	amount3 = '$amount3',
																	recurring = '$recurring',
																	reattempt = '$reattempt',
																	recur_times = '$recur_times',
																	txn_type = '$txn_type'
																	WHERE subscr_id = '$subscr_id'");

							} elseif ($dup_sid == "true") {
								//This is a new subscription
								//So we need to add a new record for it
									mysql_query("INSERT INTO accounting_paypal (
																			item_name, 
																			receiver_email, 
																			item_number, 
																			invoice, 
																			custom, 
																			txn_type, 
																			first_name, 
																			last_name, 
																			address_street, 
																			address_city, 
																			address_state, 
																			address_zip, 
																			address_country,  
																			address_status, 
																			payer_email, 
																			payer_status, 
																			subscr_date, 
																			period1, 
																			period2, 
																			period3, 
																			amount1, 
																			amount2, 
																			amount3,
																			recurring, 
																			reattempt, 
																			recur_times, 
																			username, 
																			password, 
																			subscr_id,
																			payer_id)
																	VALUES ( 
																			'$item_name', 
																			'$receiver_email', 
																			'$item_number', 
																			'$invoice', 
																			'$custom', 
																			'$txn_type', 
																			'$first_name', 
																			'$last_name', 
																			'$address_street', 
																			'$address_city', 
																			'$address_state', 
																			'$address_zip', 
																			'$address_country', 
																			'$address_status', 
																			'$payer_email', 
																			'$payer_status', 
																			'$subscr_date', 
																			'$period1', 
																			'$period2', 
																			'$period3', 
																			'$amount1', 
																			'$amount2', 
																			'$amount3', 
																			'$recurring', 
																			'$reattempt', 
																			'$recur_times', 
																			'$payer_email',
																			'$password', 
																			'$subscr_id',
																			'$payer_id')");

							};							
						} elseif ($dup_uid == "true") {
							//This is a brand new sign up.
							//Add User								

							// Insert Transaction details into DB.
								mysql_query("INSERT INTO accounting_paypal (
																			item_name, 
																			receiver_email, 
																			item_number, 
																			invoice, 
																			custom, 
																			txn_type, 
																			first_name, 
																			last_name, 
																			address_street, 
																			address_city, 
																			address_state, 
																			address_zip, 
																			address_country,  
																			address_status, 
																			payer_email, 
																			payer_status, 
																			subscr_date, 
																			period1, 
																			period2, 
																			period3, 
																			amount1, 
																			amount2, 
																			amount3,
																			recurring, 
																			reattempt, 
																			recur_times, 
																			username, 
																			password, 
																			subscr_id,
																			payer_id)
																	VALUES ( 
																			'$item_name', 
																			'$receiver_email', 
																			'$item_number', 
																			'$invoice', 
																			'$custom', 
																			'$txn_type', 
																			'$first_name', 
																			'$last_name', 
																			'$address_street', 
																			'$address_city', 
																			'$address_state', 
																			'$address_zip', 
																			'$address_country', 
																			'$address_status', 
																			'$payer_email', 
																			'$payer_status', 
																			'$subscr_date', 
																			'$period1', 
																			'$period2', 
																			'$period3', 
																			'$amount1', 
																			'$amount2', 
																			'$amount3', 
																			'$recurring', 
																			'$reattempt', 
																			'$recur_times', 
																			'$payer_email',
																			'$password', 
																			'$subscr_id',
																			'$payer_id')");
	
							//Add User
								mysql_query("INSERT INTO users (
														username, 
														password, 
														first_name, 
														last_name,
														payer_email,
														payer_id)
												VALUES (
														'$payer_email', 
														'$password', 
														'$first_name', 
														'$last_name',
														'$payer_email',
														'$payer_id')");
						};
					break;
					
					case "subscr_payment":
					
						if (strcmp ($payment_status, "Completed") == 0 ) {
							//Write or Update Record
							
							//Generate Password
							$password = makeRandomPassword();
							
							//Break apart the item_number
							list( $paid_for, $paid_time ) = split( '-' , $item_number);
							
							//Check for txn_id duplicates
							$dup_txn = checkDuptxn($txn_id);
			
							//Check for duplicates payer_id
							$dup_uid = checkDupID($payer_id);
			
							if ($dup_uid == "false" && $dup_txn = "true") {
								//The User Exists already
								//Check for duplicate subscr_id
								$dup_sid = checkDupSubID($subscr_id);
								if($dup_sid == "false") {
									//This subscription aready exist
									
									//Check if there is an existing txn_id. If not then add referral
									$ck_txn = checktxn($subscr_id);
									if ($ck_txn == "false") {
										//Add Referral
										referral($custom,"add");
										//Send Email for new subscription
										sendemail(password,$payer_email,$password);															
									} else {
										//Send Email for subscription payment
										sendemail(payment,$payer_email,"");									
									};
									
									//So we need to insert
										mysql_query("INSERT INTO accounting_paypal (
																			item_name, 
																			receiver_email, 
																			item_number, 
																			invoice, 
																			custom, 
																			payment_status, 
																			pending_reason,
																			payment_date, 
																			payment_gross, 
																			payment_fee, 
																			txn_id, 
																			txn_type, 
																			first_name, 
																			last_name, 
																			address_street, 
																			address_city, 
																			address_state, 
																			address_zip, 
																			address_country,  
																			address_status, 
																			payer_email, 
																			payer_status, 
																			payment_type,  
																			username, 
																			password, 
																			subscr_id,
																			payer_id)
																	VALUES ( 
																			'$item_name', 
																			'$receiver_email', 
																			'$item_number', 
																			'$invoice', 
																			'$custom', 
																			'$payment_status', 
																			'$pending_reason',
																			'$payment_date', 
																			'$payment_gross',
																			'$payment_fee', 
																			'$txn_id',
																			'$txn_type', 
																			'$first_name', 
																			'$last_name', 
																			'$address_street', 
																			'$address_city', 
																			'$address_state', 
																			'$address_zip', 
																			'$address_country', 
																			'$address_status', 
																			'$payer_email', 
																			'$payer_status', 
																			'$payment_type',
																			'$payer_email',
																			'$password', 
																			'$subscr_id',
																			'$payer_id')");
									
									$ck_spass = checkPassword($payer_id);								
									
									if ($ck_spass == "false") {
										mysql_query ("UPDATE users SET password = '$password' WHERE payer_id = '$payer_id'");
									};
									
								} elseif ($dup_sid == "true") {
									//This is a new subscription
									
									//First check for referral. See if this is a new subscription to an existing subscription. if it is then see if we need to move the referral to a different content or not.
									$ck_paid_for = checkPaidFor($paid_for,$payer_id);
									if ($ck_paid_for == "false") {
										//They are subscribed to this already
										//Now get the current referral
										$current_custom = getCurrentCustom($paid_for,$payer_id);
										if ($current_custom == $custom) {
											// Do Nothing they are the same
										} else {
											//They are not the same.
											referral($current_custom,"delete"); //Delete old referral
											referral($custom,"add"); //Add to new one
										};	
									} elseif ($ck_paid_for == "true") {
										//They are not subscribed to this. Just add a referral
										//Add Referral
										referral($custom,"add");
									};
									
									
									//So we need to insert
										mysql_query("INSERT INTO accounting_paypal (
																			item_name, 
																			receiver_email, 
																			item_number, 
																			invoice, 
																			custom, 
																			payment_status, 
																			pending_reason,
																			payment_date, 
																			payment_gross, 
																			payment_fee, 
																			txn_id, 
																			txn_type, 
																			first_name, 
																			last_name, 
																			address_street, 
																			address_city, 
																			address_state, 
																			address_zip, 
																			address_country,  
																			address_status, 
																			payer_email, 
																			payer_status, 
																			payment_type,  
																			username, 
																			password, 
																			subscr_id,
																			payer_id)
																	VALUES ( 
																			'$item_name', 
																			'$receiver_email', 
																			'$item_number', 
																			'$invoice', 
																			'$custom', 
																			'$payment_status', 
																			'$pending_reason',
																			'$payment_date', 
																			'$payment_gross',
																			'$payment_fee', 
																			'$txn_id',
																			'$txn_type', 
																			'$first_name', 
																			'$last_name', 
																			'$address_street', 
																			'$address_city', 
																			'$address_state', 
																			'$address_zip', 
																			'$address_country', 
																			'$address_status', 
																			'$payer_email', 
																			'$payer_status', 
																			'$payment_type',
																			'$payer_email',
																			'$password', 
																			'$subscr_id',
																			'$payer_id')");
																			
											//Send Email for new subscription
											sendemail(subscription,$payer_email,$password);															

								};							
							} elseif ($dup_txn == "true" && $dup_uid == "true") {
								//This is a brand new subscription payment
								// Insert Transaction details into DB.
									mysql_query("INSERT INTO accounting_paypal (
																			item_name, 
																			receiver_email, 
																			item_number, 
																			invoice, 
																			custom, 
																			payment_status, 
																			pending_reason,
																			payment_date, 
																			payment_gross, 
																			payment_fee, 
																			txn_id, 
																			txn_type, 
																			first_name, 
																			last_name, 
																			address_street, 
																			address_city, 
																			address_state, 
																			address_zip, 
																			address_country,  
																			address_status, 
																			payer_email, 
																			payer_status, 
																			payment_type,  
																			username, 
																			password, 
																			subscr_id,
																			payer_id)
																	VALUES ( 
																			'$item_name', 
																			'$receiver_email', 
																			'$item_number', 
																			'$invoice', 
																			'$custom', 
																			'$payment_status', 
																			'$pending_reason',
																			'$payment_date', 
																			'$payment_gross',
																			'$payment_fee', 
																			'$txn_id',
																			'$txn_type', 
																			'$first_name', 
																			'$last_name', 
																			'$address_street', 
																			'$address_city', 
																			'$address_state', 
																			'$address_zip', 
																			'$address_country', 
																			'$address_status', 
																			'$payer_email', 
																			'$payer_status', 
																			'$payment_type',
																			'$payer_email',
																			'$password', 
																			'$subscr_id',
																			'$payer_id')");
	
								//Add User
									mysql_query("INSERT INTO users (
														username, 
														password, 
														first_name, 
														last_name,
														payer_email,
														payer_id)
												VALUES (
														'$payer_email', 
														'$password', 
														'$first_name', 
														'$last_name',
														'$payer_email',
														'$payer_id')");
														
									//Add Referral
									referral($custom,"add");
									
									//Send Email for new subscription payment
									sendemail(password,$payer_email,$password);															
							};

							//Set user to paid and update custom for paid_for
							mysql_query ("UPDATE users SET $paid_for = $paid_time WHERE payer_id = '$payer_id'");
							mysql_query ("UPDATE users SET c_$paid_for = $custom WHERE payer_id = '$payer_id'");
							
							//Add Payment Information
								//Find Amount
								$pay_amount = ($payment_gross - $payment_fee);
							
								//Figure and add Payout Base for ALL contents
								$payout_base = ($pay_amount * .01);
								//if($paid_time == 1) {
									//Update all contents running total with payout_base
									mysql_query ("UPDATE Trans_contentTotals SET total=total + $payout_base");
								//} elseif($paid_time == 12) {
									//Update all contents running total with payout_base
								//	mysql_query ("UPDATE title_stats SET year=year + $payout_base");
								//};
							
								//Figure and add Payout Referral for custom content.
								$payout_ref = ($pay_amount * .20);
								//if($paid_time == 1) {
									//Update referral total where content equals custom
									mysql_query ("UPDATE Trans_contentTotals SET total=total + $payout_ref WHERE content = $custom");
								//} elseif($paid_time == 12) {
									//Update referral total where content equals custom
								//	mysql_query ("UPDATE title_stats SET year=year + $payout_ref WHERE content = $custom");
								//};
							
								//Add Pay Amount to running pay total
								//if($paid_time == 1) {
									//Update running total with pay_amount
									mysql_query ("UPDATE Trans_Total SET total=total + $pay_amount WHERE i = 1");
								//} elseif($paid_time == 12) {
									//Update running total with pay_amount
								//	mysql_query ("UPDATE income_totals SET year=year + $pay_amount WHERE i = 1");
								//};
															
						}  elseif (strcmp ($payment_status, "Pending") == 0 || strcmp ($payment_status, "Failed") == 0) {
							
							//Check if account exists. If it does change paid to not paid
								//Check for duplicate subscr_id
								$dup_sid = checkDupSubID($subscr_id);
								if($dup_sid == "false") {
									//This subscription aready exist
									mysql_query ("UPDATE users SET $paid_for = 0 WHERE payer_id = '$payer_id'");
								}
																
							//Send Email payment pending
							sendemail(pending,$payer_email,"");
						};
						
					break;
					
					case "subscr_eot":
					
						//First check against the paid time to see if they match. if they do set to 0 and delete subscription from accounts
						list( $paid_for, $paid_time ) = split( '-' , $item_number);
						$ck_paid = checkPaidTime($paid_for,$paid_time,$payer_id);
						if ($ck_paid == "false") {
							//They match we need to set paid to 0 and delete the subscription txn
								mysql_query ("UPDATE users SET $paid_for = 0 WHERE payer_id = '$payer_id'");
								//mysql_query ("DELETE FROM accounting_paypal WHERE subscr_id = '$subscr_id'");
							//Delete Referral
								referral($custom,"delete");
							//Send Email
								sendemail(cancel,$payer_email,"");
						} elseif ($ck_paid == "true") {
								//The account has been changed elsewhere and this EOT is for an older subscription
								//So we still need to delete from accounting
								//mysql_query ("DELETE FROM accounting_paypal WHERE subscr_id = '$subscr_id'");
						};							
					break;
				};
		};				
	} elseif (strcmp ($res, "INVALID") == 0) {

		sendemail(unverified,$payer_email,"");

	};
};

}

//-------------------------------------------
// Close PayPal Connection, Log File and DB.
//-------------------------------------------
fclose ($fp);
fclose ($log);
?>[/php][hr]
I’m now thinking that I just need to add something like this and it should work.

[php]
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$$key=$value;
}
[/php][hr]
Nope, that didn’t do it. Either I added it at the wrong spot (right after the $reg one) or something else is wrong.

I now get the data in the IPN log, but nothing else. No emails are being sent, and nothing is being added to the database, which doesn’t makes sense. If the vars are there now and being added to the log, there is no reason for the rest to not work.


#4

Try changing the second line of that chunk to:

[php]$value = stripslashes($value);[/php]

The urlencode() is only necessary when you’re sticking the $value into a URL.


#5

Awesome!

Actually, though, I went through and reinstated all the variables that PayPal sends at the top of the script and that works. I used PayPal to resend all the IPNs for the last couple days and they went through. I checked my database etc.

I can add that “catch all” instead, but I’d worry that it might be a security risk, but I’m not sure if that’s true.

In any event, thanks a ton for the help and suggestions. I feel relieved that it’s working again.