2012-04-26 40 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. 然后就是你为什么要在店面页面上执行管理更新任务的问题,这些页面在首先没有管理权限。
相关问题