2012-09-06 77 views
-3

我正在創建一個網站,可以讓我們使用貝寶給出的交易功能。貝寶交易

再次爲網站工作完美我使用沙箱帳戶爲我的發展。

現在有兩個名爲return和cancel_return的參數。當交易成功完成時,貝寶網站將其重定向到返回參數中提及的頁面,否則返回cancel_return參數。但網頁不重定向。同時點擊返回鏈接到網頁時顯示錯誤。

我的代碼success.php

  <?php 
      define("DB_HOST", "localhost"); 
      define("DB_USERNAME", "root"); 
       define("DB_PASSWORD", ""); 
      define("DB_DATABASE", "test"); 
      $connect = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or 
       die("Database Connection Error"); 
      mysql_select_db(DB_DATABASE) or ("Database Selection Error"); 

      session_start(); 
      $uid = $_SESSION['uid']; 
      $username=$_SESSION['username']; 

       $item_no = $_GET['item_number']; 
       $item_transaction = $_GET['tx']; 
       $item_price = $_GET['amt']; 
       $item_currency = $_GET['cc']; 

      //Getting product details 
$sql=mysql_query("select product,price,currency from products where pid='$item_no'"); 
    if($sql === FALSE) { 
     die(mysql_error()); // TODO: better error handling 
    } 
    $row=mysql_fetch_array($sql); 
     $price=$row['price']; 
     $currency=$row['currency']; 

     //Rechecking the product details 
     if($item_price==$price && $item_currency==$currency) 
    { 

    $result = mysql_query("INSERT INTO sales(pid, uid, saledate,transactionid) 
    VALUES('$item_no', '$uid', NOW(),'$item_transaction')"); 
    if($result){ 
     echo "<h1>Welcome, $username</h1>"; 
     echo '<h1>Payment Successful</h1>'; 

     }else{ 
     echo "Payment Error"; 
     } 
    } 
     else 
     { 
     echo "Payment Failed"; 
      } 
      ?> 

它不保存到數據庫中,並顯示錯誤的

Undefined index: item_number in C:\wamp\www\mvc\view\success.php on line 13 
    Undefined index: tx in C:\wamp\www\mvc\view\success.php on line 14 
    Undefined index: amt in C:\wamp\www\mvc\view\success.php on line 15 
    Undefined index: cc in C:\wamp\www\mvc\view\success.php on line 16 

感謝

+0

因爲你沒有設置任何'$ _GET'參數 –

+1

'0 down vote favorite'?你從哪個問題複製了這個問題? – nickb

回答

1

這只是一個通知錯誤。 這意味着一些$ _GET變量沒有設置。

一個例子擺脫這種錯誤消息是切換你如何分配變量...如

$item_no = isset($_GET['item_number']) ? $_GET['item_number'] : null; 

您還可以通過更改php.ini中的變量的error_reporting禁用通知,但這是不建議在開發機器上