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
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 | |
<?php } ?>
CopyRight (c) 2014
Created by Narhari Acharya
Created by Narhari Acharya