doulong4169 2015-05-06 16:56
浏览 42

php登录页面isnt重定向[关闭]

for some reason my login isn't redirecting to the required output page ive been stuck in this part for almost an hour i still cant find out whats wrong in this please help and thank you in advance !!

hoody.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());
        }
    }


?>

bye.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>

profile.php

<!DOCTYPE html>
<html>
<head>
<title>Your Home Page</title>
</head>
<body>
<div id="profile">
<b id="welcome">Welcome : <i><?php echo $login_session; ?></i></b>
<b id="logout"><a href="logout.php">Log Out</a></b>
</div>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • drake900918 2015-05-06 17:00
    关注

    You left out the header name when you called header(). It should be:

    header('Location: profile.php');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端