Results 1 to 2 of 2

Thread: IPN and PHP

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    IPN and PHP

    Hey Folks,

    Ive set up an IPN for my website and tested it through Paypal sandbox, it seems to be working but not completly, the php script I have adds the user to the database and it should also email the buyer their password for the login. The script adds the details to the database but no email is recieved. Here is my ipn.php script.
    PHP Code:
    <?php  
       
    mysql_connect
    ("blank.blank.blank""blank""blank") or die(mysql_error());  
    mysql_select_db("blank") or die(mysql_error());  
       
    // 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 ('ssl://www.paypal.com'443$errno$errstr30);
       
    if (!
    $fp) {  
    // HTTP ERROR  
    } else {  
    fputs ($fp$header $req);  
    while (!
    feof($fp)) {  
    $res fgets ($fp1024);  
    if (
    strcmp ($res"VERIFIED") == 0) {  
       
    // PAYMENT VALIDATED & VERIFIED!  
     
    $email $_POST['payer_email'];  
    $password mt_rand(10009999);  
       
    mysql_query("INSERT INTO users (email, password) VALUES('"mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error());  
       
    $to      $email;  
    $subject 'Download Area | Login Credentials';  
    $message 
      
    Thank you for your purchase 
      
    Your account information 
    ------------------------- 
    Email: '
    .$email.
    Password: '
    .$password.
    ------------------------- 
     
    You can now login at blank/'
    ;  
    $headers 'From:blank' "\r\n";  
       
    mail($to$subject$message$headers);    
    }     
    else if (
    strcmp ($res"INVALID") == 0) {  
       
    // PAYMENT INVALID & INVESTIGATE MANUALY!  
     
    $email $_POST['payer_email'];  
    $password mt_rand(10009999);  
       
    mysql_query("INSERT INTO users (email, password) VALUES('"mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error());    
    }  
    }  
    fclose ($fp);  
    }  
    ?>
    Thanks guys

  2. #2
    Join Date
    Mar 2007
    Location
    Werrington, England
    Posts
    1,315
    What I do in these situations is email myself at each turn to see where it is going wrong.

    If this is on a hosted server why don't you check your e-mail logs to find out why an e-mail isn't being sent.

    If this is on your computer, perhaps your server isn't configured to send an email

Posting Permissions

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