header("location:signin.html");根本不在实时服务器上工作
header("location:signin.html"); not at all working on live server
我已经尝试了一些用于注销的代码以销毁 session 并通过标题重定向到另一个页面..!!但是重定向根本没有发生..!plzz 帮助我..!!
form.php
<a href="sign_out.php">Sign out</a>
sign_out.php
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header('Location: signin.html'); //to redirect back to "index.php" after logging out
?>
见下文:
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
//echo "you have //just comment this echo
header("location:signin.html"); //to redirect back to "index.php" after logging out
exit();
?>
首先把echo "you have
改成echo "you have";
。在 PHP 中 header()
之前,您不能 echo
任何内容。如果你在 header 之前输出任何东西,那么它会给出一个错误。
如果你想回显之前的任何内容然后你还需要在特定条件下重定向然后使用 <script type="text/javascript">window.location.href='your_full_url';
Header return 前面写echo会报错。所以如果你使用 herder 然后不要使用 echo 如果你想回显任何东西然后使用 <script>
如下所示。
echo "<script>window.location='signin.html';</script>";
请尝试告诉我。
如果在header之前有echo
发送给客户端,这是错误的。我认为你不显示错误或警告。删除 echo "you have logged out";
如果打开错误和警告日志,您会看到:无法修改 header 信息 - headers 已经由 ...
发送
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header("location:test.html"); //to redirect back to "index.php" after logging out
?>
试试这个我自己测试过
删除<?php
开始标签前的白色space,并在脚本末尾添加exit()
,它将强制重定向。
<?php //remove white space before this tag
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header('Location: signin.html'); //to redirect back to "index.php" after logging out
exit();
?>
我已经尝试了一些用于注销的代码以销毁 session 并通过标题重定向到另一个页面..!!但是重定向根本没有发生..!plzz 帮助我..!!
form.php
<a href="sign_out.php">Sign out</a>
sign_out.php
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header('Location: signin.html'); //to redirect back to "index.php" after logging out
?>
见下文:
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
//echo "you have //just comment this echo
header("location:signin.html"); //to redirect back to "index.php" after logging out
exit();
?>
首先把echo "you have
改成echo "you have";
。在 PHP 中 header()
之前,您不能 echo
任何内容。如果你在 header 之前输出任何东西,那么它会给出一个错误。
如果你想回显之前的任何内容然后你还需要在特定条件下重定向然后使用 <script type="text/javascript">window.location.href='your_full_url';
Header return 前面写echo会报错。所以如果你使用 herder 然后不要使用 echo 如果你想回显任何东西然后使用 <script>
如下所示。
echo "<script>window.location='signin.html';</script>";
请尝试告诉我。
如果在header之前有echo
发送给客户端,这是错误的。我认为你不显示错误或警告。删除 echo "you have logged out";
如果打开错误和警告日志,您会看到:无法修改 header 信息 - headers 已经由 ...
<?php
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header("location:test.html"); //to redirect back to "index.php" after logging out
?>
试试这个我自己测试过
删除<?php
开始标签前的白色space,并在脚本末尾添加exit()
,它将强制重定向。
<?php //remove white space before this tag
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header('Location: signin.html'); //to redirect back to "index.php" after logging out
exit();
?>