php登录页面不是重定向

时间:2015-05-06 16:56:23

标签: php html web

由于某种原因我的登录没有重定向到所需的输出页面 我已经被困在这部分差不多一个小时了,我还是找不到这个错误 请帮忙 并提前谢谢!!

hoody.php

os.path.join(PATH, "some_image.gif")

bye.php

<?php 
session_start();
$error='';
if(isset($_POST['submit']))
    {
        if(empty($_POST['Uname'])||empty($_POST['psd'])){
            $error="enter the user name and password";
        } else {
            $Servername = $_POST['Uname'];
            $serverpass = $_POST['psd'];
            $conn = mysql_connect('localhost','root','') or die("could not connect to server".mysql_error());
            mysql_select_db("khader",$conn) or die ("could not connect to database".mysql_error());
            $query = "select * from person where uname = '$Servername' and pswd = '$serverpass' ";
            $loggy = mysql_query($query,$conn) or die("could not get result".mysql_error());
            $rows = mysql_num_rows($loggy);
            if($rows==1)
                {
                    $_SESSION['login_user']=$Servername;
                    header('profile.php');
                }
            else
                {
                    $error= "username and password is invalid" ;
                }
            mysql_close($conn) or die ("disconnect failed.".mysql_error());
        }
    }


?>

profile.php

<?php
include('hoody.php');
if(isset($_SESSION['login_user'])){
    header('profile.php');
}
?>

<center>
<form method="post">
  <table>
    </table>
  <p class="style1">Login</p>
  <table cellspacing="5">
  <tr></tr>
    <tr>
      <td> Username</td>
      <td><input type="text" name="Uname" /></td>
    </tr>
    <tr>
      <td> Password</td>
      <td><input type="password" name="psd" /></td>
    </tr>
     <tr></tr>
  </table>
  <input name="submit" type="submit" value="Login" />

  <span><?php echo $error; ?></span>
</form>

1 个答案:

答案 0 :(得分:3)

您在拨打header()时遗漏了标题名称。它应该是:

header('Location: profile.php');
相关问题