Hi thanks for your reply, il give you my full code so you can have a look,
Here is my check login:
<?php
session_start();
ini_set( 'display_errors', '1' );
error_reporting ( 2047 );
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "root", "root")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from signup form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result = mysql_query($sql);
if($result === false){
exit('db error: ' . mysql_error());
}
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// assign $_SESSION variables: $myusername, $mypassword and redirect to file "login_success.php"
$valuesLogin = mysql_fetch_array($result);
$mylevel = $valuesLogin['level'];
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
if($mylevel == 1){
$_SESSION['loggedin'] = "true";
header('Location: login_success.php');
} elseif($mylevel == 2){
$_SESSION['loggedin'] = "true";
header('Location: login_success2.php');
} else{
$_SESSION['loggedin'] = "true";
header('Location: login_success3.php');
}
}
else {
header("location:login_failure.php");
// echo "Wrong Username or Password";
}
exit();
?>
Her is the page that i want the admin user to be directed to:
<?php
session_start();
if($_SESSION['loggedin'] != "true") {
header("Location: main_login.html");
}
else {
?>
<html>
<head>
<title>Car Rentals & Returns</title>
<meta http-equiv="Content-Type" content="text/html" />
<link href="style2.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper3">
<img src="images/cars.jpg" width="996" height="100"></a>
<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<td align="center">
<H1>Main Menu Administrator</H1>
</td>
</table>
<TABLE BGCOLOR="#F0F8FF" BORDER=0 CELLPADDING=10 WIDTH=100%>
<tr>
<TD ALIGN=CENTER VALIGN=TOP WIDTH=50>
</TD>
<TD ALIGN=LEFT VALIGN=TOP WIDTH=83%>
</TABLE>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="addnewuser.html">
<input type="submit" class="mybutton" value="Add new employee"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="search_emp.html">
<input type="submit" value="Search for employee" class="mybutton"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="customer_2.html">
<input type="submit" value="Add new customer" class="mybutton"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="search2.html">
<input type="submit" value="Search for customer" class="mybutton"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="load.html">
<input type="submit" value="Add new car" class="mybutton"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="car.html">
<input type="submit" value="Search for car" class="mybutton"/></TD>
</tr>
</form></table>
<TABLE BGCOLOR="#F0F8FF" WIDTH=100%>
<TR><TD ALIGN="center">
<form method="post" action="Logout.php">
<input type="submit" value="Logout" class="mybutton"/><BR><BR><BR></TD>
</tr>
</form>
</table>
</td>
</form>
</tr>
</table>
</BODY>
</HTML>
<?
}
?>