显示消息后使用标头方法重定向


Redirect with header method after showing message

我想显示此消息,然后在几秒钟后重定向到index.php。

echo "Se efectuó el borrado del alumno con dicho mail.";``

我的问题是它会自动重定向到 index.php,但我看不到该消息。

<html>
<head>
<title>Problema</title>
</head>
<body>
<?php
$conexion=mysql_connect("localhost","root","strlen12") or
  die("Problemas en la conexion");
mysql_select_db("base1",$conexion) or
  die("Problemas en la selección de la base de datos");
$sql="select codigo from alumnos
                        where mail='$_REQUEST[mail]'";
#echo $sql;
$registros=mysql_query($sql,$conexion) or
  die("Problemas en el select:".mysql_error());

if($reg=mysql_fetch_array($registros)){
   mysql_query("delete from alumnos where mail='$_REQUEST[mail]'",$conexion) or
    die("Problemas en el select:".mysql_error());
  echo "Se efectuó el borrado del alumno con dicho mail.";
  header('Location: index.php');
}
else{
    echo "No existe un alumno con ese mail.";
}
mysql_close($conexion);
?>
</body>

尝试设置延迟:

header( "Refresh:5; url=http://www.example.com/index.php");

因此,您可以显示消息并在 5 秒后重定向到索引

它正在打印消息,但您无法看到它,因为它会立即重定向到index.php页面。

如果要index.php页面上显示此消息。您需要在那里echo此消息。

要在 index.php 上显示此消息。

1)使用Javascript或Jquery http://blazonry.com/javascript/windows.php 创建一个弹出窗口,并在其中插入您的消息。

2)只需像在现有页面上一样echo消息。

编辑:我不会推荐它。但是除了Napster的答案之外,还可以快速解决您的问题。

 echo "<script type='text/javascript'>alert('Really annoying pop-up!');</script>";

如果您想为您的网站提供花哨的东西,例如显示加载 gif 或消息。我会说只是看看这个小教程。将来也可能对您有所帮助。"http://banagale.com/display-a-simple-loading-message-and-animated-loading-gif-using-javascript.htm":)