Ameslee Posted June 23, 2006 Share Posted June 23, 2006 Hey hope someone can help. I have at the moment a website that is connected to a database. I have created a login area, which connects to maintenance pages. I have user levels, so if someone logs in and there username so happens to be Admin or Owner, there allowed in with different access abilities. but i have one problem at the moment, i can login, but i can when i go to access any of the maintenace pages it throughs me back out to the homepage.Here is my code that i have used. please help.[code]<?phpsession_start();header("Cache-control: no-cache");//this includes the database connectioninclude("database.inc");//Get the user's input from the form $username = trim($_POST['user']);//Get the user's input from the form $password = trim($_POST['pass']);//check username and password are correct$users_query = "SELECT * FROM user where username = '$user' AND password = '$pass'";//echo $users_query;$mysql_result=mysql_query($users_query,$conn);$row=mysql_fetch_row($mysql_result);//if valid user doesnt exist set the error message and redirect to badlogin pageif ($username==""){//echo "nooo";header("Location: ");}else{//if valid user exists set all the session variables//$row is the record, [3] is the 3rd element(field) in the array$_SESSION['Level']=$username[5];$_SESSION['username']=$username[1];//redirect to the page you want to allow the user to access//echo "yesss";header(" ");}?>[/code]The security code:[code]<?phpsession_start();if ($_session['level'] != "Admin" && $_session['level'] != "Owner" }{ header("Location: login.php");}?>[/code]Any help is apprieciated, thanks Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 23, 2006 Share Posted June 23, 2006 [code]if ($_session['level'] != "Admin" && $_session['level'] != "Owner" } [/code]Should be $_SESSION not $_session, but the line ending } should be a )[code]if ($_SESSION['level'] != "Admin" && $_SESSION['level'] != "Owner" ) [/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.