rattlsnak Posted September 5, 2008 Share Posted September 5, 2008 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 More sharing options...
justsomeguy Posted September 5, 2008 Share Posted September 5, 2008 $_SESSION['email'] = $rowAccount['email'];$_SESSION['level'] = $rowaccount['level']; Link to comment Share on other sites More sharing options...
rattlsnak Posted September 5, 2008 Author Share Posted September 5, 2008 Son of a @!%$^# ! OK better now.. THANKS! Link to comment Share on other sites More sharing options...
justsomeguy Posted September 6, 2008 Share Posted September 6, 2008 When in doubt, print it out. If you would have printed $_SESSION['level'] you would have seen that it was empty. Link to comment Share on other sites More sharing options...
DaleEss Posted September 8, 2008 Share Posted September 8, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.