include "dbcontroller.php";
    $db = new DBController();
    // check whether the payment_status is Completed
    $isPaymentCompleted = false;
    if ($payment_status == "Completed") {
        $isPaymentCompleted = true;
    }
    // check that txn_id has not been previously processed
    $isUniqueTxnId = false;
    $result = $db->selectQuery("SELECT * FROM payments WHERE txn_id = '{$txn_id}'");
    if (empty($result)) {
        $isUniqueTxnId = true;
    }
    // check that receiver_email is your PayPal email
    // check that payment_amount/payment_currency are correct
    if ($isPaymentCompleted && $isUniqueTxnId && $payment_amount == "0.01" && $payment_currency == "USD") {
        $payment_id = $db->insertQuery("INSERT INTO payment(item_number, item_name, payment_status, payment_amount, payment_currency, txn_id) VALUES('{$item_number}', '{$item_name}', {$payment_status}, '{$payment_amount}', '{$payment_currency}', '{$txn_id}')");
    }
    // process payment and mark item as paid.
    if (DEBUG == true) {
        error_log(date('[Y-m-d H:i e] ') . "Verified IPN: {$req} " . PHP_EOL, 3, LOG_FILE);
    }
} else {
    if (strcmp($res, "INVALID") == 0) {
        // log for manual investigation
        // Add business logic here which deals with invalid IPN messages
        if (DEBUG == true) {
            error_log(date('[Y-m-d H:i e] ') . "Invalid IPN: {$req}" . PHP_EOL, 3, LOG_FILE);
        }
    }
}
Пример #2
0
    if (!isset($message)) {
        if (!isset($_POST["gender"])) {
            $message = " Gender field is required";
        }
    }
    /* Validation to check if Terms and Conditions are accepted */
    if (!isset($message)) {
        if (!isset($_POST["terms"])) {
            $message = "Accept Terms and conditions before submit";
        }
    }
    if (!isset($message)) {
        require_once "dbcontroller.php";
        $db_handle = new DBController();
        $query = "INSERT INTO reg(first_name, last_name, DOB, contact, email, gender, nationality, occupation, home_addr) VALUES\n\t\t( '" . $_POST["firstName"] . "', '" . $_POST["lastName"] . "', '" . $_POST["dob"] . "', '" . $_POST["cnumber"] . "',  '" . $_POST["userEmail"] . "' ,  '" . $_POST["gender"] . "',  '" . $_POST["nationality"] . "', '" . $_POST["occ"] . "', '" . $_POST["home_add"] . "')";
        $result = $db_handle->insertQuery($query);
        if (!empty($result)) {
            $message = "You have registered successfully!";
            unset($_POST);
        } else {
            $message = "Problem in registration. Try Again!";
        }
    }
}
?>
<html>
<head>
<title>PHP User Registration Form</title>
<style>
.message {color: #FF0000;font-weight: bold;text-align: center;width: 100%;padding: 10;}
body{width:610px;}