小弟我用header如何进行跳转

WBOY
Release: 2016-06-13 13:14:47
Original
910 people have browsed it

我用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');

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!