This is my header.php
The only problem i am facing is that the notice on the bottom of my screen but login is working properly as it should be.When I submit username and password it pass through another page.The notice shows error on if($_SESSION['login_id']=="").
<?php
var_dump($_SESSION);
if($_SESSION['login_id']=="")
{
?>
| <a href="index.php?page=login">Login</a> |
<?php
}
else
{
echo "<font color='green'> | Welcome ".$_SESSION['login_usr']." ".$_SESSION['login_id']." | Logged in as ".$_SESSION['type']." | </font>";
if($_SESSION['type']=="Admin")
{
?> <a href="index.php?page=main_record_officer">
<?php
}
if($_SESSION['type']=="Student")
{
?> <a href="index.php?page=main_student">
<?php }
if($_SESSION['type']=="Teacher")
{
?><a href="index.php?page=main_teacher">
<?php }
if($_SESSION['type']=="Accountant")
{
?><a href="index.php?page=main_accountant">
<?php } ?>
My Page</a> | <a href="logoff.php">Logoff</a> | <?php
}
?>
<a href="index.php?page=help">Help</a> |
This is my login.php
<?php
if(isset($_POST['submit_btn']))
{
$user=$_POST['usrname'];
$pass=$_POST['password'];
$sql="select * from record_officer where admin_name='$user' and admin_password='$pass'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
if($count==1)
{
$_SESSION['login_usr']=$row['admin_name'];
$_SESSION['login_id']=$row['admin_id'];
$_SESSION['type']="Admin";
print "<script>window.location='index.php?page=main_record_officer';</script>";
}
else if($pass==""||$user=="")
{
echo "<center><font color='red'>Required fields are empty !!! </font></center><br><br>";
}
else
{
echo "<center><font color='red'>Invalid user name and password !!! </font></center><br><br>";
}
}
?>