douchan7552 2014-11-28 06:52
浏览 76

删除记录后PHP页面不会自动重新加载?

After the record deletion i have send header to previous page but it's not happen how could i solved it..

record is already deleted but it still show in that page after pressing ctrl + f5 when page is reload from server at that time the effect of deletion is show.

<?php
     include('../config.php');
    $table=$_REQUEST['table'];
    mysql_query("DELETE FROM ".$table." WHERE id=".$id);
    $_SESSION['message']="Deleted Successfully....";

    header('Location: ' . $_SERVER['HTTP_REFERER']);

?>

also in all the pages happening same thing adter edit add and all the data base action is showing effect after ctrl+f5 press...

  • 写回答

2条回答 默认 最新

  • dow72046 2014-11-28 07:10
    关注

    You have not initialised the variable $id

    mysql_query("DELETE FROM ".$table." WHERE id=".$id); // Where is $id initialized?
    

    Did you forget to add

    $id = $_REQUEST['id'];
    

    If your $id is not initialised, definitley, mysql_query will execute some query like:

    DELETE FROM ".$table." WHERE id=

    Which will not conclude to anything and hence, no delete will occur.

    Notes:

    1) Do not use mysql_ functions are they are deprecated and will be removed in upcoming PHP versions.

    2) You are feeding a variable coming from $_REQUEST directly to your SQL. The variable needs to be sanitized.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序