mercredi 6 mai 2015

php login page isnt redirecting

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>

Aucun commentaire:

Enregistrer un commentaire