日期:2014-05-17  浏览次数:20553 次

我用header怎么进行跳转啊
我原来有一个login.php,验证用户名和密码正确后我在php中使用
  echo "<script>";
  echo "window.location='profile.php'";
  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>";
  //echo "window.location='profile.php'";
  //echo "</script>";
  header('Location:192.168.1.55/login/profile.php');
  //login在htdoc下面
  }
  else
  {
  echo "<script>";
  echo "document.getElementById('login_result').style.visibility='visible';";
  echo "document.getElementById('login_result').innerHTML='Username or passworld error.';";
  echo "</script>";
  }
  }
  else
  {
  echo "<script>";
  echo "document.getElementById('login_result').style.visibility='visible';";
  echo "document.getElementById('login_result').innerHTML='Service cannot connect,try later';";
  echo "</script>";
  }
  }
  else
  {
  exit;
  }

------解决方案--------------------
你这个js跟php没关系,改成这样,
加上http://

header('Location: http://192.168.1.55/login/profile.php');