繁体   English   中英

在zen-cart中从一页重定向到另一页时如何解决错误

[英]how to resolve error while redirecting from one page to another in zen-cart

我想在更改下拉列表中的选项时更新数据库的值。 更新后,ctrl重定向回到订单页面。 现在,更新工作正常,但无法返回到订单页面。 我正在使用以下代码。

订单中的代码

<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));
}
}

?>

您的代码中存在几个问题:

  1. 您的代码中存在严重的SQL Injection漏洞。 您需要先清理您的输入,然后才能在数据库查询中使用它们。 如果有人发现您的页面并尝试使用流氓输入,则可能会严重损坏您的数据库。

  2. 与字符串值进行比较时,不能将数据库对象用作操作数。

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

您可以只用zen_redirect行替换它,而无需if()语句,因为无论如何都将进行重定向。

  1. 然后是整个问题,为什么您要在店面页面上执行管理更新任务,而这些页面首先没有管理权限。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM