Hello,
I need help to modify an IPN script from paypal i have a registration script that the user fills in but i want to be able to transfer there variables to the IPN script, what i want the IPN script to do is change the users inactive status to active within a mysql table but for the ipn script to do that it needs to know which user to update so once theyve signed up i want there variables passed on to the IPN script so it knows what to update?

i really need help on this?

    You didn't provide anything for us to help on. In this case, the code snippet that submits the IPN data to the IPN table and the user db table format would be helpful. As it stands, there's nothing anyone could say here that would assist you.

    thanks,
    json

      schwim;10909568 wrote:

      You didn't provide anything for us to help on. In this case, the code snippet that submits the IPN data to the IPN table and the user db table format would be helpful. As it stands, there's nothing anyone could say here that would assist you.

      thanks,
      json

      well what i want the IPN script to update is the users active status
      so when the user registers it is automatically set to inactive and what i want the IPN to do is change it to active but i want to somehow transfer the variables the user entered into the registration script into the IPN script so the IPN script knows which user to update. here is the ipn script

        the Ipn script is to long to post though :/

          You usually don't supply the whole script when only having a problem with a particular portion. Look through the script and find the portion that updates the IPN tables on a successful payment and post that. Also posting your table structure for your users would allow someone to tailor the sql statement to do what you're looking to do.

          thanks,
          json

            //check if transaction ID has been processed before
            $checkquery = "select txnid from paypal_payment_info where txnid='".$txn_id."'";
            $sihay = mysql_query($checkquery) or die("Duplicate txn id check query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
            $nm = mysql_num_rows($sihay);
            if ($nm == 0){
            
            //execute query
            
            
            
            if ($txn_type == "cart"){
            $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
            
             $result = mysql_query($strQuery) or die("Cart - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
             for ($i = 1; $i <= $num_cart_items; $i++) {
                 $itemname = "item_name".$i;
                 $itemnumber = "item_number".$i;
                 $on0 = "option_name1_".$i;
                 $os0 = "option_selection1_".$i;
                 $on1 = "option_name2_".$i;
                 $os1 = "option_selection2_".$i;
                 $quantity = "quantity".$i;
            
                 $struery = "insert into paypal_cart_info(txnid,itemnumber,itemname,os0,on0,os1,on1,quantity,invoice,custom) values ('".$txn_id."','".$_POST[$itemnumber]."','".$_POST[$itemname]."','".$_POST[$on0]."','".$_POST[$os0]."','".$_POST[$on1]."','".$_POST[$os1]."','".$_POST[$quantity]."','".$invoice."','".$custom."')";
                 $result = mysql_query($struery) or die("Cart - paypal_cart_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
            
             }
            }
            
            
            
            else{
             $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
             $result = mysql_query("insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,itemnumber,itemname,os0,on0,os1,on1,quantity,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$item_number."','".$item_name."','".$option_name1."','".$option_selection1."','".$option_name2."','".$option_selection2."','".$quantity."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')") or die("Default - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
            }
            
            
            // send an email in any case
             echo "Verified";
                 mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
            }
            else {
            // send an email
            mail($notify_email, "VERIFIED DUPLICATED TRANSACTION", "$res\n $req \n $strQuery\n $struery\n  $strQuery2");
            }
            
            //subscription handling branch
            if ( $txn_type == "subscr_signup"  ||  $txn_type == "subscr_payment"  ) {
            
              // insert subscriber payment info into paypal_payment_info table
              $strQuery = "insert into paypal_payment_info(paymentstatus,buyer_email,firstname,lastname,street,city,state,zipcode,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";
              $result = mysql_query($strQuery) or die("Subscription - paypal_payment_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
            
            
            
                 // insert subscriber info into paypal_subscription_info table
                $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3,  mc_amount1,  mc_amount2,  mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$mc_amount2."','".$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
                $result = mysql_query($strQuery2) or die("Subscription - paypal_subscription_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
            
            
                     mail($notify_email, "VERIFIED IPN", "$res\n $req\n $strQuery\n $struery\n  $strQuery2");
            
            }
            
            }
            

            and this is the sql query to create the table for users

            CREATE TABLE `users` (
            `id` int(20) NOT NULL auto_increment,
            `full_name` varchar(200) collate latin1_general_ci NOT NULL default '',
            `user_name` varchar(200) collate latin1_general_ci NOT NULL default '',
            `user_pwd` varchar(200) collate latin1_general_ci NOT NULL default '',
            `user_email` varchar(200) collate latin1_general_ci NOT NULL default '',
            `user_activated` int(1) NOT NULL default '0',
            PRIMARY KEY (`id`)
            )

              Ok, for you to be able to do this, one of the payment variables should match one of your user variables.

              // insert subscriber info into paypal_subscription_info table
              $strQuery2 = "insert into paypal_subscription_info(subscr_id , sub_event, subscr_date ,subscr_effective,period1,period2, period3, amount1 ,amount2 ,amount3, mc_amount1, mc_amount2, mc_amount3, recurring, reattempt,retry_at, recur_times, username ,password, payment_txn_id, subscriber_emailaddress, datecreation) values ('".$subscr_id."', '".$txn_type."','".$subscr_date."','".$subscr_effective."','".$period1."','".$period2."','".$period3."','".$amount1."','".$amount2."','".$amount3."','".$mc_amount1."','".$mc_amount2."','".$mc_amount3."','".$recurring."','".$reattempt."','".$retry_at."','".$recur_times."','".$username."','".$password."', '".$txn_id."','".$payer_email."','".$fecha."')";
              $result = mysql_query($strQuery2) or die("Subscription - paypal_subscription_info, Query failed:<br>" . mysql_error() . "<br>" . mysql_errno());
              

              And it looks to me like your user specific information would be $username or $payer_email, although, a lot of times, payer email doesn't match your user records, so we'll hope that $username was supplied by either the site or the user and that it does match your database of users.

              So adding this right below the above statement might do what you want it to do:

              $strQuery3("UPDATE users SET active = '1' WHERE user_name = $username") or die("Cannot query the database.<br><br>" . mysql_error());
              

              I hope this helps.

              thanks,
              json

                Could you edit your previous post and put all code inside

                [ php ]

                [ /php ]

                tags(without the spaces)? It will keep the page from stretching and allow others to read your code with less hassle.

                thanks,
                json

                  How do i edit my posts?

                  and also will the IPN now which username to edit because all the other information such as payment_info and that comes from paypal itself as all the username and password is like processed through a process.php which does all the important stuff like add the username to the database heres the code below

                  <?
                  	include ("auth.php");
                  	$connection = mysql_connect($dbhost, $dbusername, $dbpassword);
                  	$db = mysql_select_db($dbname);
                  
                  // EDIT THIS IF YOU MODIFIED THE SIGNUP PAGE OR
                  // IF YOU ARE USING YOUR OWN SIGNUP FORM
                  // We  use the addslashes() function on some variables to prevent SQL Injection
                  $username = addslashes($_POST['username']);
                  $password = $_POST['password'];
                  $fname = $_POST['fname'];
                  $lname = $_POST['lname'];
                  $email = addslashes($_POST['email']);
                  $country = $_POST['country'];
                  $zipcode = $_POST['zipcode'];
                  
                  // SIGNUP SETTINGS
                  $qSetup = mysql_query("SELECT * FROM signupsetup");
                  $SetupRow = mysql_fetch_array($qSetup);
                  $ValidEmailDomains = $SetupRow['validemail'];
                  $profile = $SetupRow['profile'];
                  $defaultgroup = $SetupRow['defaultgroup'];
                  $defaultlevel = $SetupRow['defaultlevel'];
                  $AutoApprove = $SetupRow['autoapprove'];
                  $AutoSend = $SetupRow['autosend'];
                  $AutoSendAdmin = $SetupRow['autosendadmin'];
                  
                  // EMAILER SETTINGS
                  $qEmailer = mysql_query("SELECT * FROM emailer WHERE profile='$profile'");
                  $EmailerRow = mysql_fetch_array($qEmailer);
                  $EmailerName = $EmailerRow["name"];
                  $EmailerFrom = $EmailerRow["email"];
                  $EmailerSubject = $EmailerRow["subject"];
                  $EmailerMessage = $EmailerRow["emailmessage"];
                  
                  // SIGNUP FORM PROCESSING
                  $EmailQuery = mysql_query("SELECT * FROM signup WHERE email='$email'");
                  $email = strtolower($email);
                  $EmailExist = mysql_num_rows($EmailQuery);	// Returns 0 if not yet existing
                  $username = strtolower($username);
                  $UsernameQuery = mysql_query ("SELECT * FROM signup WHERE uname='$username'");
                  $UsernameExist = mysql_num_rows($UsernameQuery);
                  
                  if (trim($ValidEmailDomains)=="")
                  {
                  	$EmailArray = "";
                  }
                  else
                  {
                  	$EmailArray = split (" ", $ValidEmailDomains);
                  }
                  
                  // Generate confirmation key for settings which require one
                  $confirmkey =  md5(uniqid(rand())); 
                  
                  // CHECK FOR RESERVED USERNAMES
                  if (trim($username)=='sa' || trim($username)=='admin' || trim($username)=='test')
                  {
                  	$UsernameExist = 1;
                  }
                  
                  // CHECK FOR REQUIRED FIELDS
                  if (empty($username))
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Username field cannot be left blank!</b></font></p>";
                  	exit;
                  }
                  if (empty($password))
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Password field cannot be left blank!</b></font></p>";
                  	exit;
                  }
                  if (empty($fname))
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>First Name field cannot be left blank!</b></font></p>";
                  	exit;
                  }
                  if (empty($lname))
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Last Name field cannot be left blank!</b></font></p>";
                  	exit;
                  }
                  if (empty($email))
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email field cannot be left blank!</b></font></p>";
                  	exit;
                  }
                  
                  // Validate Email Address String
                  $good = ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
                             '@'.
                             '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
                             '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
                             $email);	
                  if (!$good)
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email field has invalid characters!</b></font></p>";
                  	exit;
                  }
                  
                  // Validate Email Address String - FOR VALID EMAIL DOMAINS
                  $found=false;
                  if ($EmailArray!="")
                  {
                  	for ($ct=0;$ct<=sizeof($EmailArray)-1;$ct++)
                  	{
                  		if (eregi($EmailArray[$ct], $email))
                  		{
                  			$ct=sizeof($EmailArray);
                  			$found=true;
                  		}
                  		else
                  		{
                  			$found=false;
                  		}
                  	}
                  }
                  else
                  {
                  	$found = true;
                  }
                  if (!$found)
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email address does not belong to the list of allowable email domains!</b></font></p>";
                  	exit;
                  }
                  
                  // Make sure username does not yet exist in the db
                  if ($UsernameExist>0)
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Username already exists in the database!</b></font></p>";
                  	exit;
                  }
                  
                  // Make sure email address does not yet exist in the db
                  if ($EmailExist>0)
                  {
                  	print "<p><font size=\"3\" face=\"Verdana, Arial\" color=\"#FF0000\"><b>Email address already exists in the database!</b></font></p>";
                  	exit;
                  }
                  
                  // *********************************************************
                  // CHANGE THIS IF YOU WANT TO ADD FIELDS TO YOUR SIGNUP FORM
                  // *********************************************************
                  // Add new member to table signup
                  $addmember = mysql_query("INSERT INTO signup VALUES ('','$username','$fname','$lname','$email','$country','$zipcode',NOW(),'$confirmkey')");
                  
                  // If SUCCESSFUL, add to vAuthenticate tables too
                  if ($addmember)
                  {
                  	// Is the member auto-approved or not?
                  	if ($AutoApprove==1)
                  	{
                  		$MemberStatus = "active";
                  	}
                  	else
                  	{
                  		$MemberStatus = "inactive";
                  	}
                  
                  	$AddToAuth = new auth();
                  	$add = $AddToAuth->add_user($username,$password,$defaultgroup,$defaultlevel,$MemberStatus,'', 0);
                  }
                  
                  // Do we automatically send email notification to member or not?
                  if ($AutoSend == 1)
                  {
                  	// if successful in adding to vAuthenticate, send confirmation email
                  	if ($add==1)
                  	{	
                  		// Replace all occurrences of the keys
                  		// AVAILABLE KEYS: [[UNAME]], [[LNAME]], [[FNAME]], [[PASSWD]], [[EMAIL]], [[CONFIRM]]			
                  		$EmailerMessage = str_replace("[[UNAME]]", $username, $EmailerMessage);
                  		$EmailerMessage = str_replace("[[PASSWD]]", $password, $EmailerMessage);
                  		$EmailerMessage = str_replace("[[FNAME]]", $fname, $EmailerMessage);
                  		$EmailerMessage = str_replace("[[LNAME]]", $lname, $EmailerMessage);
                  		$EmailerMessage = str_replace("[[EMAIL]]", $email, $EmailerMessage);
                  		$EmailerMessage = str_replace("[[CONFIRM]]", $confirm . '?confirmkey=' . $confirmkey, $EmailerMessage);
                  
                  		$sent = @mail($email, $EmailerSubject, $EmailerMessage, "From:$EmailerName<$EmailerFrom>\nReply-to:$EmailerFrom"); 
                  		// $sent = @mail($email, $EmailerSubject, $EmailerMessage, "From:$EmailerName<$EmailerFrom>\nReply-to:$EmailerFrom\nContent-Type: text/html; charset=iso-8859-15"); 
                  	}
                  }
                  // echo $EmailerMessage;	// DEBUGGER
                  
                  // Do we automatically send notification message to the admin's email address (see signupconfig.php)?
                  if ($AutoSendAdmin == 1)
                  {
                  	if ($add==1)
                  	{
                  		$AdminSubject = "New Membership Application!";
                  		$AdminMessage = "This is to inform you that " . $username . " has applied for membership to our site.";			
                  		$sent = @mail($adminemail, $AdminSubject, $AdminMessage, "From:$EmailerName<$EmailerFrom>\nReply-to:$EmailerFrom"); 
                  	}
                  }
                  ?>
                  
                  <p><font size="3" face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000"><b>Thank 
                    you for signing up!</b></font></p>
                  
                  <?
                  	if ($AutoSend == 1) 
                  	{
                  		print "<p><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
                  		print "A confirmation email was sent to the email address you specified. <br>";
                  		print "Please confirm your membership as soon as you receive the email.";
                    		print "</font></p>";
                  	}
                  	else
                  	{
                  		print "<p><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
                  		print "Please click <a href=\"$RelLogin\">here</a> to go back to the login area";
                    		print "</font></p>";
                  	}
                  ?>
                  

                  because i was wanderin would you have to make a string or something like that or use the include ( " "); command to include it and then put some code in the process.php but im not sure if it would work

                    This code snippet is from the confirm.php this is meant to go with the confirmation email so when the user clicks on the link the users status is changed from inactive to active but i don't want the confirmation email to change the status i want the IPN to change the status so i'm not sure but would this code help?

                    // authuser table
                    		$row = mysql_fetch_array($AuthResult);
                    		$password = $row["passwd"];
                    		$team = $row["team"];
                    		$level = $row["level"];
                    		$status = $row["status"];
                    	}
                    
                    // Make member active
                    $x = new auth();
                    $Activate = $x->modify_user($username, '', $team, $level, "active");
                    

                      Editing posts: Chances are great that the forum admins, in all their knowledge, don't allow editing of posts after a certain time period, to protect from the three people in the history of the internet that abused the privilege of being able to edit their comments. 🙂

                      As for your question on whether what I posted would get the username info that you need. I can't say for sure, but I can tell you this. The code snippet that you posted and that I reposted was populating the $username cell in the paypal_subscription_info with information. All I did was tell it to modify the active field where the username that was supplied earlier matched.

                        Post edited. See the Coding Forum's FAQ for more information about available code-formatting tags. (Tell you what, though, lines of source code that long are not easy for humans to read in any case: source code is supposed to be readable by humans.)

                          Write a Reply...