I have a Paypal IPN script that logs all the transactions perfectly into a database log. I am trying to add a script that is “required” from the original script after all the authorizations are completed in the original script.
The script works fine except that I am drawing a blank on how to format the logic to only effect a single value in the User data base without affecting all of the other values in the database that are set by the IPN transaction.
I need to only make changes when the appropriate values are made for the appropriate product. I having only been writing PHP code for a month and I apologize for not being able to find the proper methods.
Here is the code:
[php]<?php
require(‘createconnect.php’);
if(isset($_POST[‘submitted’]))
if(empty($_POST[‘item_name’]))
die(‘You failed to receive item information.’);
$User = $_POST['custom'];
$Product = $_POST['item_name'];
$Payment = $_POST['mc_fee'];
if($Product == Emp && $Payment == 10.00) {
$Emp = ‘1’;
} else if ($Product == Emp && $Payment == 15.00){
$Emp = ‘2’;
} else if ($Product == Emp && $Payment == 20.00){
$Emp = ‘3’;
}
$query = (‘UPDATE Users ‘.
‘SET EMP = "’.mysqli_real_escape_string($dbcon, $Emp).’" ‘.
‘WHERE User_Id = "’.mysqli_real_escape_string($dbcon, $User).’"’);
if($Product == Biz && $Payment == 10.00) {
$Biz = ‘1’;
} else if ($Product == Biz && $Payment == 15.00){
$Biz = ‘2’;
} else if ($Product == Emp && $Payment == 20.00){
$Biz = ‘3’;
}
$query = (‘UPDATE Users ‘.
‘SET BIZ = "’.mysqli_real_escape_string($dbcon, $Biz).’" ‘.
‘WHERE User_Id = "’.mysqli_real_escape_string($dbcon, $User).’"’);
if(!mysqli_query($dbcon, $query)) {
die(‘error inserting into database. Please email [email protected].’);
} // end of nested if statement
?>[/php]