Hi,
I currently have a php/mysql login page that works fine, but I'd like to incorporate some code that redirects users to specific pages based on login info. Since I'm very new to PHP (like 15mins!), any assistance would greatly be appreciated!
Here's a piece of my login.php script:
session_start();
require("dbconnect.php");
$log = "SELECT * FROM tbl_user_accts WHERE uname='".$_POST['uname']."'";
$qlog = mysql_query($log) or die("Cant Get UserData!");
$rlog = mysql_fetch_array($qlog);
if($rlog['proj_id']=='0')
{
$error = "The Project for this account is already deleted!";
include ("index2.php");
}
elseif(($_POST['uname'] == $rlog['uname']) && ($_POST['pw'] == $rlog['pw']) && ($_POST['uname']!='') && ($_POST['pw']!=''))
{
setcookie("user", "active", time()+3600);
mysql_query("INSERT into tbl_logs (uid, last_log) VALUES ('".$rlog['uid']."',now())") or die(mysql_error()."Cant Write Log!");
$_SESSION['uid'] = $rlog['uid'];
$_SESSION['pid'] = $rlog['proj_id'];
header('Location:main.php?uid='.$rlog['uid']);
More info about login: upon creation, each user name is assigned to a specific project. The database assigns a project id (proj_id) to each. As for the user_accts table, here are the variables: uid, uname, pw, proj_id and proj_type.
What I'd like to happen: after authentication and a project id is identified, I'd like the login script to check the "proj_type" variable in the user_accts database for that project id. I've assigned values of "live" and "archive" to "proj_type". Each project with have one or the other. If a project is "live", the login script will redirect to live.php; if "archive, then archive.php.
I think I need 2 IF statements before the header command. That's as far as my PHP knowledge goes.
Thanks for your help! Jeff