Login Help

I want to login into backend and front end with same login page maintained over index.php page for all staff and student. Please let me knoe if it is possible.
The code I am using is:

<?php session_start(); ?> Login Page
<?php include("config.php"); if(isset($_POST['submit'])) { $user = $_POST['username']; $pass = $_POST['password'];
if($user == "" || $pass == "")
{
	echo "Either username or password field is empty.";
	echo "<br/>";
	echo "<a href='index.php'>Go back</a>";
}
else
{
	$result = mysql_query("select * from login where username='$user' and password='$pass'",$conn)
	or die("Could not execute the select query.");
	
	$row = mysql_fetch_assoc($result);
	
	if(is_array($row) && !empty($row))
	{
		$validuser = $row['username'];
		$_SESSION['valid'] = $validuser;
	}
	else
	{
		echo "Invalid username or password.";
		echo "<br/>";
		echo "<a href='index.php'>Go back</a>";
	}

	if(isset($_SESSION['valid']))
	{
		header('Location: employee.php');			
	}
}

}
else
{

?>

System Login Area
















Username
Password
 




Forgot your password? Click here to reset it.


<?php } ?>
CopyRight (c) 2014
Created by Narhari Acharya

How are the users differentiated between able to view the back end and front end? eg. Access Levels

If you do not already have it, at minimum you will need to create user roles (Access Levels). A more advanced way, is to do the user roles with permissions for each role.

Sponsor our Newsletter | Privacy Policy | Terms of Service