I just added a user log on page to my site that allows you to see the page only when logged in. I am also in the need to make some links shown only when an admin is logged in. The way I have it now is users are ranked 1 for admin and 2 for user. I was thinking of having a while statement of sorts that will only show a link if a user is ranked as a 1. the problem is I don't know how I would pass on the rank of the user in the session.
Thanks in advance.
here's what I have to create the session
and here's what I put in the header that will be on each page.PHP Code:<?php
//connection info
$sql="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_start();
$_SESSION['login'] = "1";
header ("Location:index.php");
} else {
$errorMessage = "Invalid Login";
session_start();
$_SESSION['login'] = '';
}
?>
As this is my first user log in I will take any pointers on how to make it better.PHP Code:
<?php
session_start();
if(!$_SESSION['login']){
header("location:login.php");
}
?>


