Jump to content

redirecting users based on level


rattlsnak
 Share

Recommended Posts

OK, I had this working on another site, but for some reason it wont work on the one I'm currently working on.I need certain users to be directed to one page, and others to another. I have this:A login page with a form, that submits to a check page:$query="SELECT * FROM userdatabase WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($query);$rowAccount=mysql_fetch_array($result);if($rowAccount){session_start();$_SESSION['user'] = $rowAccount['user'];$_SESSION['username'] = $rowAccount['username'];$_SESSION['email'] = $rowAccount['email'];$_SESSION['level'] = $rowaccount['level'];header("location:homelevel1.php");}else {header("location:loginerror.php");}Which if found a valid user, goes to homelevel1.php, and on that page I have this at the top:session_start();if (! isset($_SESSION['user'])){header("location:login.php");}elseif ($_SESSION['level'] == '2'){header ("location:homelevel2.php");}But no matter who logs in, it goes to the homelevel1 page.I tried changing the session id to 'level', and changing the else if, to just an if statement, but niether works.Should I redirect it from the first check page? How?OK, what i am doing wrong?

Link to comment
Share on other sites

i dont use the but i have found using my way to be easyer link all users to the page membershome.phpand use<?php if($info->userlevel=='1'){die("type page here or just use a include("memeber/level1.php");");} ?>need any more helpemail dksnowdon@googlemail.com or feel free to contant 07988591878

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...