follow this code...
<?php session_start();
include('conn.php');
$Name = $_POST['login_id'];
$Pass = $_POST['password'];
$select="select * from admin_login where admin_name='$Name' AND admin_pwd='$Pass'";
$query=mysql_query($select) or die($select);
$rows=mysql_fetch_array($query);
$row=mysql_num_rows($query);
if($row != 0)
{
$_SESSION['admin_name']=$rows['admin_name'];
echo "<script>window.location.href='index.php'</script>";
}else
{
$message = 'Invalid Username Or Password';
echo '<script type="text/javascript">alert("'.$message.'")</script>';
echo "<script>window.location.href='login.php'</script>";
}
?>
put this code to the top of the every page
<?php session_start();
if(isset($_SESSION["admin_name"])=='') print('<script>window.location.href="login.php"</script>');