2012-04-26 18 views
0

我想在更改下拉列表中的選項時更新數據庫的值。上調後ctrl重定向回訂單頁面。現在更新工作正常,但無法恢復到訂單頁面。我爲此使用了以下代碼。如何解決錯誤,同時在禪車中從一個頁面重定向到另一個頁面

代碼orders.php

<select name="order_status" onchange="update(this.value,<?php echo $row['orders_id'];?>)"> 
    <option value="1" <?php if($row['orders_status']=='1'){ ?>selected="selected"<?php } ?>>In process</option> 
    <option value="2"<?php if($row['orders_status']=='2'){ ?>selected="selected"<?php } ?>>Processed</option> 
    <option value="3"<?php if($row['orders_status']=='3'){ ?>selected="selected"<?php } ?>>Dispatched</option> 
    </select> 

      <script> 
      function update(vals,order){ 
       window.location="index.php?main_page=orders&val="+vals+"&id="+order; 
      } 
      </script> 


<?php 
if(($_REQUEST['id']) && ($_REQUEST['val'])){ 

    $manufacturers = $db->Execute("update orders set orders_status = '{$_REQUEST['val']}' 
            where orders_id ='{$_REQUEST['id']}'"); 

if($manufacturers == '1'){ 
zen_redirect(zen_href_link('orders', '', $request_type)); 
} 
} 

>

+0

...錯誤是? – 2012-04-27 10:58:26

回答

0

有幾個問題在你的代碼:

  1. 你在你的代碼,嚴重的SQL注入漏洞。在數據庫查詢中使用它們之前,您需要對輸入進行清理。如果有人發現您的頁面並嘗試使用惡意輸入,他們可能會嚴重損壞您的數據庫。

  2. 與字符串值進行比較時,不能將數據庫對象用作操作數。

    if($manufacturers == '1'){ 
        zen_redirect(zen_href_link('orders', '', $request_type)); 
    } 
    

你也許可以替換隻用zen_redirect線路,而無需if()語句,因爲你會做重定向不管。

  1. 然後就是你爲什麼要在店面頁面上執行管理更新任務的問題,這些頁面在首先沒有管理權限。
相關問題