Here is the login page where user and admin logs
$username = trim(mysql_prep($_POST['username']));
$password = trim(mysql_prep($_POST['password']));
if (empty($errors)){
if (!$username){
$message = "username field is empty!";
}else if (!$password){
$message = "password field is empty!";
}else{
// ********** Authenticate user details ************
$cpassword = sha1($password);
$query = "SELECT * FROM users WHERE surname = '{$username}' AND password = '{$cpassword}' AND position = 'admin' LIMIT 1";
$result_set = mysql_query($query);
confirm_query($result_set);
if (mysql_num_rows($result_set) == 1){
// ********** checks the result from db *************
$found_user = mysql_fetch_array($result_set);
$_SESSION['user_id'] = $found_user['id'];
$_SESSION['username'] = $found_user['surname'];
redirect_to("admin.php");
}else{
//redirect_to("index.php");
$message = "username or password is incorrect";
}
}
}else {
if (count($errors) == 1) {
$message = 'there was 1 error in the form';
}else {
$message = 'there were ' . count($errors) . ' errors in the form';
}
}
<form name="user" method="post" action="log.php" >
<input id="uname" type="text" name="username" placeholder="Enter your username" value="<?php echo htmlentities($username); ?>"/><br /><br />
Password:<br />
<input id="pass" type="password" name="password" placeholder="Enter your password" value="<?php echo htmlentities($password); ?>"/><br /><br />
<input id="Signin" type="submit" name="Submit" value="Sign in" /><br /><br />
</form>