页面未按预期加载

时间:2017-07-02 16:18:32

标签: php

我正在测试成功页面,该页面在使用paypal(ipn)的交易成功完成后加载。所有数据都成功保存到ipn阶段的数据库中,但由于某种原因,我使用的成功页面不会加载我提取的任何变量。在这种情况下$last_insert_id

唯一回应的是单词success但是当我点击重新加载变量出现时。有人可以解释我的错误。感谢。

Success.php

<?php
include 'dbconnection.php';

//Get payment information from PayPal
$item_number = $_GET['item_number']; 
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];
$item_name = $_GET['item_name'];

//Get product price from database
$productResult = $db->query("SELECT price FROM products WHERE id = '".$item_number."'");
$productRow = $productResult->fetch_assoc();
$productPrice = $productRow['price'];

if(!empty($txn_id) && $payment_gross == $productPrice){
    //Check if payment data exists with the same TXN ID.
    $prevPaymentResult = $db->query("SELECT payment_id FROM payments WHERE txn_id = '".$txn_id."'");

    if($prevPaymentResult->num_rows > 0){
        $paymentRow = $prevPaymentResult->fetch_assoc();
        $last_insert_id = $paymentRow['payment_id'];
    }

    echo "success";
    echo $last_insert_id;
} else{
    echo "error";    
}
?>

0 个答案:

没有答案