Rumah > Artikel > pembangunan bahagian belakang > 小弟我用header如何进行跳转
我用header怎么进行跳转啊
我原来有一个login.php,验证用户名和密码正确后我在php中使用
echo "<script>";<br /> echo "window.location='profile.php'";<br /> echo "</script>";进行跳转,结果我同事在ipad中用safari浏览,点击登陆按钮毫无反应,username和password在地址栏能看到。我在pc上用safari就能登陆。
我想是不是我用window.location原因,把验证登录提取到login2.php中,想使用header进行跳转,在pc和ipad上登陆有就停留在login2.php不给我跳转。
login2.php文件:
$rootdoc = $_SERVER['DOCUMENT_ROOT'];
require_once $rootdoc.'/login/db/db.php';
define ("DEBUG",TRUE);
if(isset($_REQUEST['username'])&&isset($_REQUEST['pw']))
{
$username=$_REQUEST['username'];
$pw=$_REQUEST['pw'];
if(DEBUG)
{
$database=new db('localhost','root','090807','practice');
}
else
{
$database=new db('','','','');
}
$result=$database->query('','users',"username='$username' and password='$pw'");
if($result)
{
$count= mysql_num_rows($result);
if($count)
{
$row=mysql_fetch_array($result);
$_SESSION['cuid']=$row['id'];
//echo $_SESSION['cuid'];
//echo "<script>";<br /> //echo "window.location='profile.php'";<br /> //echo "</script>";
header('Location:192.168.1.55/login/profile.php');
//login在htdoc下面
}
else
{
echo "<script>";<br /> echo "document.getElementById('login_result').style.visibility='visible';";<br /> echo "document.getElementById('login_result').innerHTML='Username or passworld error.';";<br /> echo "</script>";
}
}
else
{
echo "<script>";<br /> echo "document.getElementById('login_result').style.visibility='visible';";<br /> echo "document.getElementById('login_result').innerHTML='Service cannot connect,try later';";<br /> echo "</script>";
}
}
else
{
exit;
}
------解决方案--------------------
你这个js跟php没关系,改成这样,
加上http://
header('Location: http://192.168.1.55/login/profile.php');