1. 876.
    0
    <?php

    mysql_connect("localhost", "dbuser", "dbpass") or die(mysql_error());
    mysql_select_db("DB") or die(mysql_error());

    // read the data send by PayPal
    $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.0rn";
    $header .= "Content-Type: application/x-www-form-urlencodedrn";
    $header .= "Content-Length: " . strlen($req) . "rnrn";

    $fp = fsockopen (' http://ssl://www.paypal.com ', 443, $errno, $errstr, 30);
    if (!$fp) {
    // HTTP ERROR
    } else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED")

    0) {
    // PAYMENT VALID

    }

    else if (strcmp ($res, "INVALID")

    0) {

    // PAYMENT INVALID

    }
    }
    fclose ($fp);
    }
    ?>
    ···
   tümünü göster