Question

what is the problem in this code...??? it is not redirecting to the other page but stay on the login.php page (Blank Page)... Database are all correct... can someone help me on this code... your help is much appreciated...

<?
require_once('include/config.php');
require_once('include/functions.php');

session_start();

session_destroy();

$message="";


$Login=$_POST['Login'];
if($Login){ // If clicked on Login button.
$username=$_POST['username'];
$md5_password=md5($_POST['password']); // Encrypt password with md5() function.



mysql_select_db("$db", $con);


$result=mysql_query("select * from staff where stf_username='$username' and    stf_password='$md5_password'");
$sql =mysql_query("select stf_level from staff where stf_username='$username'");


if(mysql_num_rows($result)!='0'){ // If match.
session_register("username");
while($row = mysql_fetch_array($sql))
{
//echo $row['level'] . " ";
if($row['stf_level'] == 1){
header("location:admin/index.php");
}
elseif($row['stf_level'] == 2){
header("location:cashier/index.php");
 }
 elseif($row['stf_level'] == 3){
 header("location:waiter/index.php");
 }
 elseif($row['stf_level'] == 4){
 header("location:kitchen/index.php");
 }
 }

//header("location:main.php"); // Re-direct to main.php
exit;
}else{ // If not match.
$message="--- Incorrect Username or Password ---";
}

} // End Login authorize check.
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />

<meta name="description" content="Description" />
<meta name="keywords" content="Keywords" />

<meta name="author" content="Aafrin" />


<title>iCafe Login</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="css/keyboard.css" />
<script type="text/javascript"      src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<script type="text/javascript" src="js/keyboard.js"></script> 

</head>

<body>
<div id="wrapper">

<div id="loginPanel">
<img class="image" alt="" src="images/logo.png" width="220" height="120" />
<div id="error"><? echo $message; ?></div>

<form id="form" name="form" method="post" action="<? echo $PHP_SELF; ?>">

    <label>Username :</label>
        <input type="text" name="username" class="keyboardInput" />

    <label>Password :</label>
        <input type="password" name="password" class="keyboardInput"  />

    <input name="Login" type="submit" id="Login" value="Login" class="submit" />
    <!--    
    <input type="submit" value="Submit" name="submit" class="submit"  />
    -->

</form>

<div id="footer">
XYZ © 2012 - All Rights Reserver | Powered By <a     href="http://www.facebook.com/kesavans">Kesavan</a>
</div>

</div>
<!--
<div id="details">
<p>Login Details</p>
Admin : admin
<br />
Waiter : waiter
<br />
Kitchen : kitchen
<br />
Cashier : cash
</div>
-->
</body>

</html>

No correct solution

OTHER TIPS

try @header("") may be you have an error. Why dont you save all the location in a variable and pass the variable to the header function?

if($x=1){$loc="admin/index.php"}
if($x=2){$loc="staff/index.php"}
if($x=3){$loc="manager/index.php"}
@header('location:$loc')

i think you should put space after the : it will be like

header("location: cashier/index.php");

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top