header()貌似没有跳转 求帮助

WBOY
Release: 2016-06-23 14:14:47
Original
1197 people have browsed it

只是接收数据对比,然后分别指向2个php页面,php页面都在一个路径下。form表单提交后没有反应怎么回事。。。
$username = $_POST['username'];
$password = $_POST['passwd'];
if($password == "123"){
header("Location:friendlist.php");
}else{
header("Location:login.php");
}
?>


UserName:


PassWord:



回复讨论(解决方案)

需要在header中的*.php文件前加个http://localhost/../*.php

如;$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');

如;$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
能否再说详细点?HTTP_HOST是指http://localhost/*.php吗 
PHP_SELF是不是指接收数据的这个php页面?

$username = $_POST['username'];
$password = $_POST['passwd'];
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
if($password == "123"){
header("Location:http://$host$uri/friendlist.php");
}else{
header("Location:http://$host$uri/login.php");
}

直接上一上代码[hide]teste[/hide]

你当前页面是 logincontroller.php吗,
因为: action="logincontroller.php"

$username = $_POST['username'];
$password = $_POST['passwd'];
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
if($password == "123"){
header("Location:http://$host$uri/friendlist.php");
}else{
header("Location:http://$host$uri/login.php");
}
解决了!谢谢 请问这个是什么问题导致的 这两句代码是什么意思?

可以去查看一下php手册。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template