Jump to content


  • Posts

  • Joined

  • Last visited


Posts posted by cmgmyr

  1. Ok, here is what I got...

    donations table:
    CREATE TABLE `donations` (
    `item_name` MEDIUMTEXT NOT NULL ,
    `item_number` MEDIUMTEXT NOT NULL ,
    `payment_status` TEXT NOT NULL ,
    `payment_amount` TEXT NOT NULL ,
    `payment_currency` TEXT NOT NULL ,
    `txn_id` LONGTEXT NOT NULL ,
    `receiver_email` MEDIUMTEXT NOT NULL ,
    `payer_email` MEDIUMTEXT NOT NULL ,
    INDEX ( `id` )

    I have a donations part in the users table also.



    echo "<form action=\"https://www.sandbox.paypal.com/cgi-bin/webscr\" method=\"post\">
    <input type=\"hidden\" name=\"cmd\" value=\"_xclick\">
    <input type=\"hidden\" name=\"business\" value=\"Business Name\">
    <input type=\"hidden\" name=\"item_name\" value=\"item name\">
    <input type=\"hidden\" name=\"item_number\" value=\"1\">
    <input type=\"hidden\" name=\"currency_code\" value=\"USD\">
    <input type=\"hidden\" name=\"receiver_email\" value=\"email\">
    <input type=\"hidden\" name=\"mrb\" value=\"R-3WH47588B4505740X\">
    <input type=\"hidden\" name=\"pal\" value=\"ANNSXSLJLYR2A\">
    <input type=\"hidden\" name=\"no_shipping\" value=\"1\">
    <input type=\"hidden\" name=\"no_note\" value=\"1\">
    <input type=\"hidden\" name=\"notify_url\" value=\"http//www.URL to script/ipn.php?UID=$userid\">
    <input type=\"hidden\" name=\"cancel_return\" value=\"http//www.URL to users script/users.php\">
    <input type=\"image\" name=\"submit\" src=\"http://images.paypal.com/images/x-click-butcc-donate.gif\" border=\"0\" alt=\"Make payments with PayPal, it's fast, free, and secure!\">



    include "connect.php";
    function ipn_verify($seller_email = '', $item_price = '', $currency = ''){
        return array('result' => 0);

      //seed random generator
      mt_srand((double)microtime() * 1000000);
      $charset = "abcdefghijklmnopqrstuvwxyz12_-34567890ABCDE_FGHIJKLMNOPQRSTWXYZ";

      // 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.sandbox.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_amount = sprintf("%.2f", $payment_amount);
      $payment_currency = $_POST['mc_currency'];
      $txn_id = $_POST['txn_id'];
      $receiver_email = $_POST['receiver_email'];
      $payer_email = $_POST['payer_email'];

      $trans_details = array('item_name' => $item_name, 'item_number' => $item_number, 'payment_status' => $payment_status, 'payment_amount' => $payment_amount, 'payment_currency' => $payment_currency, 'txn_id' => $txn_id, 'receiver_email' => $receiver_email, 'payer_email' => $payer_email);

        // HTTP ERROR
        fputs($fp, $header . $req);
          $res = fgets($fp, 1024);
          fclose ($fp);
          if((strcmp($res, 'VERIFIED') == 0)){
            $failed = 0;
            if(($seller_email) && ($seller_email != $receiver_email)){
              $failed = 1;
            if(($item_price) && (sprintf("%.2f", $item_price) < sprintf("%.2f", $payment_amount))){
              $failed = 1;
            if(($currency) && ($currency != $payment_currency)){
              $failed = 1;
              $trans_details['result'] = 1;
              return $trans_details;
              $trans_details['result'] = 0;
              return $trans_details;
          }elseif(strcmp ($res, 'INVALID') == 0){
            $trans_details['result'] = 0;
            return $trans_details;

    $trans_details = ipn_verify('email'); //same e-mail address as above

      @mysql_query("insert into donations (UID, item_name, item_number, payment_status, payment_amount, payment_currency, txn_id, receiver_email, payer_email) values ('". $_GET['UID'] ."', '". $trans_details['item_name'] ."', '". $trans_details['item_number'] ."', '". $trans_details['payment_status'] ."', '". $trans_details['payment_amount'] ."', '". $trans_details['payment_currency'] ."', '". $trans_details['txn_id'] ."', '". $trans_details['receiver_email'] ."', '". $trans_details['payer_email'] ."')");
      $getter = @mysql_fetch_object(mysql_query("SELECT * FROM users WHERE userid='". $_GET['UID'] ."' limit 1"));
      $donations = sprintf("%.2f", ($trans_details['payment_amount'] + $getter->donations));
      @mysql_query("update users set donations='". $donations ."' where userid='". $_GET['UID'] ."' limit 1");
      echo '<center>Thank you for your donation.</center>';
      echo '<center>We\'re sorry but your donation has failed.</center>';
    include "disconnect.php";

    In my sandbox account I went to Profile>Instant Payment Notification> I enabled it and used http//www.URL to script/ipn.php as the URL and saved it. The payments are going in and out of the right accounts as they should, but it's not updating the database. Am I missing something?

  2. If you have phpMyAdmin it gives you a breakdown of each table and how much space is taken up and a total on the bottom for everything combined.

    The amount of space depends on what you are holding in the database. What kind of information are you holding? But I think 1 gig should be enough.

  3. I agree with everyone's comments so far. I do like the layout and the design. BUT your site is a techy site, why don't you make it more techy looking? More modern looking. Right now it looks fine, but it's looks like a design site, not a techy site.

  4. On your laptop you would have to go into phpMyAdmin (install it if you haven't) go to export and make sure you get data and structure. Open up phpMyAdmin in 1and1 make a new database, go to sql and import your saved sql from your laptop. Update your config file with the information that 1and1 gives you for their database and you should be all set

  5. They are like cookies...but not. Cookies are stored on the user's computer and sessions are on the server. So if you have information getting checked all of the time from 2 different sources you shouldn't have anything to worry about.
  6. Hey, Thanks guys. I knew that paypal had the IPN system, but I never really worked with it before. I saw that zend tutorial, but I was looking for something a little simpler. I signed up as a paypal developer so that I can have sandbox accounts. I guess I just have to jump in right?

    Do you guys have any advise in what works and what doesn't?

    Thanks again,
  7. Hey all,
    I've been all over online looking for some good paypal/php tutorials and couldn't really what I was looking for. Here is what I want to do:
    -User comes into the system and has to make a donation
    -Makes a donation through paypal
    -Completes the payment through paypal
    -Script updates my database with the amount

    I know I can do this my making a success script, but that only works if the user clicks "return to merchant" which if you close your browser out, it will not update the database.

    I know that you can do it, but I haven't found any real good references.

    Any ideas or help?

  8. You can also check out Sweet Titles at http://www.dustindiaz.com/download/ it basically takes whatever you have in the title atribute of a link or image and displays a nice little box.

  9. Also what i've noticed is that IE doesn't like it when you drop the </div> down to the next line. It treats this like a space or a line break in some cases.

    Try changing it to this:[code]<div style="width: 180px; padding-left: 5px;">
    <div style="float:left; background-image: url('images/menu-title-left.gif');
    background-repeat: no-repeat; width: 14px; height: 25px;"></div>
    <div style="float:right; background-image: url('images/menu-title-right.gif');
    background-repeat: no-repeat; width: 14px; height: 25px;"></div>
    <div style="background-image: url('images/menu-title-repeat.gif');
    background-repeat: repeat-x; margin:0; padding: 0; padding-top: 8px;
    font-weight: bold; font-size: 11pt; color: #fff; height: 17px;">
    Main Menu</div>
    <div style="clear:both; border: 1px solid #999; background-color: #ddd;">
      <ul class="leftmenu">
    <li><a href="">Home</a></li>
    <li><a href="">About</a></li>
    <li><a href="">Guestbook</a></li>

    I don't know why it does that, but it does. I had the same problem a while ago and I tried that and it worked. If it doesn't work for you, then just make the top all one image like what moberemk said.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.