PHP重定向无法正常工作

时间:2015-10-14 10:47:39

标签: php url redirect url-redirection

我正在尝试使用php标头成功用户登录后重定向我的页面,但我无法重定向页面。

"
 Command "c:\python27\python.exe -c "import setuptools,tokenize;__file__='c:\\us    
 ers\\admini~1\\appdata\\local\\temp\\pip-build-e3yebj\\scipy\\setup.py';exec(com
 pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
 ile__, 'exec'))" install --record c:\users\admini~1\appdata\local\temp\pip-mwhxl
 d-record\install-record.txt --single-version-externally-managed --compile" faile
 d with error code 1 in c:\users\admini~1\appdata\local\temp\pip-build-e3yebj\sci
 py
"

我的登录页面位于“georamble”文件夹中。我哪里错了?

3 个答案:

答案 0 :(得分:2)

如果echo语句在header之前使用,那么不能重定向页面。所以你也可以尝试这个。 echo <script> window.location =&#39; url&#39; </script>

答案 1 :(得分:0)

您可能收到错误,因为您在重定向之前打印信息。您的用户永远不会看到该信息。

A similar question and answer.

因此,在脚本成功执行暗示登录后,如果要显示某种类型的信息,则在标题重定向中传递参数。因为您只是回应有效登录,我认为不需要。你做对了,在重定向之前就不能在屏幕上打印任何内容。

答案 2 :(得分:0)

你不能使用,在标题之前回显。要克服这种情况,您可以使用 ob_start() ob_end_flush() 功能,如下所示:< / p>

ob_start();
echo '<span style="color:#E02F2F;text-align:center;font-size:25px;padding-left:38%;">Username or Password is valid</span>';
header('Location:http://example.com/templates/georamble/index.php'); // Redirecting To Other 
ob_end_flush();

希望这可以帮助你。

相关问题