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

WBOY
Freigeben: 2016-06-23 14:14:47
Original
1164 Leute haben es durchsucht

只是接收数据对比,然后分别指向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手册。

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!