dapcigar Posted May 9, 2014 Share Posted May 9, 2014 i want my login page to redirect to different pages depending on the id provided.. the code below.. include('mysql_connect.php'); $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' LIMIT 1"); if(mysql_num_rows($sql) == 1){ $row = mysql_fetch_array($sql); session_start(); $_SESSION['username'] = $row['username']; $_SESSION['firstname'] = $row['firstname']; $_SESSION['lastname'] = $row['lastname']; $_SESSION['department'] = $row['department']; $_SESSION['logged'] = TRUE; if ($position == "Admin") { header("Location: admin/Admin_dash.php"); exit; } if ($position == "HOD" && $department == "Account") { header("Location: hod/hod_dash.php"); exit; } else { header("Location: staff/staff_dash.php"); exit; } Please, how can i retrieve the position from the DB and use it to run an IF statement? Quote Link to comment https://forums.phpfreaks.com/topic/288370-login-issue/ Share on other sites More sharing options...
ginerjm Posted May 9, 2014 Share Posted May 9, 2014 As I was reading your code the first question that came to mind was "where is $position coming from" But you question at the end resolved that one and created a new one. What do you mean "retrieve the position"? Is position a field in your table - just add it to the query. If not, where does position come from? Quote Link to comment https://forums.phpfreaks.com/topic/288370-login-issue/#findComment-1478878 Share on other sites More sharing options...
JustinStone Posted May 10, 2014 Share Posted May 10, 2014 (edited) I'm not that good at PHP, but I'll try to help. It sounds like you have different types of members, admins and just members. I would create a row in the database and call it 'Level'. When a normal member signs up, give them a Level 0. And then all Admins would have a level 1 which could just be manually put in the database. So then you have two different level types of members. On your redirect have it check if the member that is signed in is a Level 1 or Level 0, and then redirect accordingly. Like I said, I don't know that much about PHP, but that is what I would do. Hope that helps. Also, I think posting the login form and the full login script would help lots. Edited May 10, 2014 by JustinStone Quote Link to comment https://forums.phpfreaks.com/topic/288370-login-issue/#findComment-1478959 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.