Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除函数PHP MYSQL JAVASCRIPT后返回主页_Javascript_Php_Mysql_Alert - Fatal编程技术网

删除函数PHP MYSQL JAVASCRIPT后返回主页

删除函数PHP MYSQL JAVASCRIPT后返回主页,javascript,php,mysql,alert,Javascript,Php,Mysql,Alert,对不起,我是初学者,我想问一下,在Delete.php之后,如何从主页或特定页面返回。它只是一个空白页面 编辑 删除成功后看起来是这样的 这是我的密码: delete.php <?php session_start(); include_once 'dbconnect.php'; $id = $_GET['id']; $sql = mysql_query("DELETE FROM accounts where user_id='$id'"); i

对不起,我是初学者,我想问一下,在Delete.php之后,如何从主页或特定页面返回。它只是一个空白页面

编辑

删除成功后看起来是这样的

这是我的密码:

delete.php

<?php
    session_start();
    include_once 'dbconnect.php';
    $id = $_GET['id'];
    $sql = mysql_query("DELETE FROM accounts where user_id='$id'");

    if ($sql > 0) {
?>
    <script> alert('Record has been successfully deleted'); </script>
<?php
    } else {
?>
    <script> alert('Database Error!'); </script>
<?php
    }
?>

警报('数据库错误!');
下面是我调用delete.php函数的地方:

<td>
    <a href="delete.php?id=<?php echo $row['user_id']; ?>" onclick="return confirm('Are you sure?');">
        Delete
    </a>
</td>

您可以使用

header('Location:any_page.php');
exit;
在delete.php中,您可以使用

header('Location:any_page.php');
exit;

在delete.php中使用javascript window.location

<?php
   session_start();
   include_once 'dbconnect.php';

   $id=$_GET['id'];
   $sql=mysql_query("DELETE FROM accounts where user_id='$id'");

   if($sql > 0) {
   ?>

  <script> alert('Record has been successfully deleted'); 
window.location.replace("page name");

</script>

  <?php
 } else{ 
  ?>

  <script> alert('Database Error!'); 
window.location.replace("page name");
 </script>

 <?php
  }
  ?>

警报('数据库错误!');
窗口。位置。替换(“页面名称”);

使用javascript window.location

<?php
   session_start();
   include_once 'dbconnect.php';

   $id=$_GET['id'];
   $sql=mysql_query("DELETE FROM accounts where user_id='$id'");

   if($sql > 0) {
   ?>

  <script> alert('Record has been successfully deleted'); 
window.location.replace("page name");

</script>

  <?php
 } else{ 
  ?>

  <script> alert('Database Error!'); 
window.location.replace("page name");
 </script>

 <?php
  }
  ?>

警报('数据库错误!');
窗口。位置。替换(“页面名称”);

。。。警报(“记录已成功删除”);是这样吗?是的。any_page.php是要重定向到的php文件。如果您正在重定向到home.php,它与delete.php位于同一文件夹中。然后使用header('Location:home.php');请确保您输入了正确的文件和正确的路径。非常感谢。上帝保佑。。。。警报(“记录已成功删除”);是这样吗?是的。any_page.php是要重定向到的php文件。如果您正在重定向到home.php,它与delete.php位于同一文件夹中。然后使用header('Location:home.php');请确保您输入了正确的文件和正确的路径。非常感谢。上帝保佑,拉哈斯是对的answer@Rahautos答案是对的你很棒,非常感谢,上帝保佑你!你很棒,非常感谢,上帝保佑你!