Hi, I am doing a school project in which I have to different pages load after login based on whether the user is a regular employee or administrator. I want their to be a default control panel, and then add a header based on if its an employee or admin. The following code I have isn’t working, I was wondering if somebody could help me out as to why?
<?php
ob_start();
DATABASE CONNECTING CODE
mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$is_admin = false;
$sql="SELECT * FROM employee WHERE username='$username' and pass='$password'";
$result=mysql_query($sql);$count=mysql_num_rows($result);
$sql = "SELECT is_admin FROM employee WHERE username = $username LIMIT 1";
$query = mysql_query( $sql );
$data = mysql_fetch_array( $query );
if ( $data['is_admin'] == 1 ) {
$is_admin = true;
}
if ($count==1) {
session_register("username");
session_register("password");
header("location:control_panel.php"); }
elseif ( $is_admin == true ) {
include_once('header_admin.php'); }
elseif ( $is_admin == false ) {
include_once('header_employee.php');}
else
echo "Wrong Username or Password";
ob_end_flush();
?>