Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: help with code

  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with code

    hello every one i have some code here for my site its supposed to take and tell you to put your id#from my site then call on the name then call out to paypal but for some reason its not doing it when i put it in my page it doesnt do anything am i missing something here any help would be appreciated this is the code


    <?<br>include "dbcon.php";

    function Send_Event ($id, $text){

    $timesent = time();
    $text = mysql_real_escape_string($text);
    $result= mysql_query("INSERT INTO `events` (`to`, `timesent`, `text`)".

    "VALUES ('$id', '$timesent', '$text')");

    }
    function microtime_float()

    {

    $time = microtime();

    return (double)substr( $time, 11 ) + (double)substr( $time, 0, 8 );

    }

    $time = microtime_float();

    // 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, 30);

    // assign posted variables to local variables
    $item_name = $_POST['item_name'];
    $item_number = $_POST['item_number'];
    $payment_status = $_POST['payment_status'];
    $payment_amount = $_POST['mc_gross'];
    $payment_currency = $_POST['mc_currency'];
    $txn_id = $_POST['txn_id'];
    $receiver_email = $_POST['receiver_email'];
    $payer_email = $_POST['payer_email'];
    $first = $_POST['first_name'];
    $last = $_POST['last_name'];
    $quantity = $_POST['quantity'];
    $user_id = $_POST['custom'];



    $result1000 = mysql_query("INSERT INTO `ipn` (`itemname`, `date`, `itemnumber`, `paymentstatus`, `paymentamount`, `currency`, `txnid`, `receiveremail`, `payeremail`, `first`, `last`, `quantity`, `user_id`)"."VALUES ('".$item_name."', '$time', '".$item_number."', '".$payment_status."', '".$payment_amount."', '".$payment_currency."', '".$txn_id."', '".$receiver_email."', '".$payer_email."', '".$first."', '".$last."', '".$quantity."', '".$user_id."')");

    $result2 = mysql_query("SELECT*FROM `grpgusers` WHERE `id`='".$user_id."'");
    $worked = mysql_fetch_array($result2);

    if ($item_number == 1 && $payment_status == "Completed"){
    $usermoney = $worked['bank'] + 10000;
    $userpoints = $worked['points'] + 50;
    $userrmdays = $worked['rmdays'] + 30;
    $result = mysql_query("UPDATE `grpgusers` SET `rmdays`='".$userrmdays."', `points`='".$userpoints."', `bank`='".$usermoney."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");

    }

    if ($item_number == 2 && $payment_status == "Completed"){
    $usermoney = $worked['bank'] + 25000;
    $userpoints = $worked['points'] + 125;
    $userrmdays = $worked['rmdays'] + 60;
    $result = mysql_query("UPDATE `grpgusers` SET `rmdays`='".$userrmdays."', `points`='".$userpoints."', `bank`='".$usermoney."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 3 && $payment_status == "Completed"){
    $usermoney = $worked['bank'] + 75000;
    $userpoints = $worked['points'] + 300;
    $userrmdays = $worked['rmdays'] + 90;
    $result = mysql_query("UPDATE `grpgusers` SET `rmdays`='".$userrmdays."', `points`='".$userpoints."', `bank`='".$usermoney."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 4 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 250;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 5 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 500;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 6 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 1000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 7 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 2500;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 8 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 5000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 9 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 10000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 10 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 20000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 11 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 30000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 12 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 50000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 13 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 85000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been cedited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 14 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 100000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    if ($item_number == 15 && $payment_status == "Completed"){
    $userpoints = $worked['points'] + 250000;
    $result = mysql_query("UPDATE `grpgusers` SET `points`='".$userpoints."' WHERE `id`='".$user_id."'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    $result = mysql_query("SELECT * FROM `inventory` WHERE `userid`='".$user_id."' AND `itemid`='42'");
    $worked2 = mysql_fetch_array($result);
    $itemexist = mysql_num_rows($result);

    if($item_number == 16 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('42', '".$user_id."', '1')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 16 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 1;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='42'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 17 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('42', '".$user_id."', '5')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 17 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 5;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='42'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 18 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('42', '".$user_id."', '20')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number > 18 && $itemexist == 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 25;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='42'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 19 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('42', '".$user_id."', '50')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 19 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 50;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='42'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 20 && $payment_status == "Completed"){
    $quantity = $worked['colordays'] + 30;
    $result = mysql_query("UPDATE `grpgusers` SET `colordays` = '".$quantity."' WHERE `id`='$user_id'");
    Send_Event($user_id, "Your 30 name color days has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 21 && $payment_status == "Completed"){
    $quantity = $worked['colordays'] + 60;
    $result = mysql_query("UPDATE `grpgusers` SET `colordays` = '".$quantity."' WHERE `userid`='".$user_id."'");
    Send_Event($user_id, "Your 60 name color days has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 22 && $payment_status == "Completed"){
    $quantity = $worked['colordays'] + 90;
    $result = mysql_query("UPDATE `grpgusers` SET `colordays` = '".$quantity."' WHERE `userid`='".$user_id."'");
    Send_Event($user_id, "Your 90 name color days has just been credited. Transaction id: ".$txn_id." ");
    }
    $result = mysql_query("SELECT * FROM `inventory` WHERE `userid`='".$user_id."' AND `itemid`='81'");
    $worked2 = mysql_fetch_array($result);
    $itemexist = mysql_num_rows($result);

    if($item_number == 23 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('81', '".$user_id."', '10')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 23 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 10;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='81'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    $result = mysql_query("SELECT * FROM `inventory` WHERE `userid`='".$user_id."' AND `itemid`='82'");
    $worked2 = mysql_fetch_array($result);
    $itemexist = mysql_num_rows($result);

    if($item_number == 24 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('82', '".$user_id."', '10')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 24 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 10;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='82'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    $result = mysql_query("SELECT * FROM `inventory` WHERE `userid`='".$user_id."' AND `itemid`='83'");
    $worked2 = mysql_fetch_array($result);
    $itemexist = mysql_num_rows($result);

    if($item_number == 25 && $itemexist == 0 && $payment_status == "Completed"){
    $result= mysql_query("INSERT INTO `inventory` (`itemid`, `userid`, `quantity`)"."VALUES ('83', '".$user_id."', '10')");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }
    if($item_number == 25 && $itemexist > 0 && $payment_status == "Completed"){
    $quantity = $worked2['quantity'] + 10;
    $result = mysql_query("UPDATE `inventory` SET `quantity` = '".$quantity."' WHERE `userid`='".$user_id."' AND `itemid`='83'");
    Send_Event($user_id, "Your ".$item_name." has just been credited. Transaction id: ".$txn_id." ");
    }

    ?>

  • #2
    Regular Coder
    Join Date
    Dec 2008
    Posts
    133
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Just as a head's up, change this line:
    PHP Code:
    <?<br>include "dbcon.php";
    to:

    PHP Code:
    <?php include "dbcon.php";

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Please wrap your code in PHP tags, thanks
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •