close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

after login redirect to page according to user_level

Thread began 2/24/2011 6:17 am by info105077 | Last modified 6/01/2015 5:22 pm by info105077 | 55462 views | 27 replies

aati424262

after login redirect to page according to user_level

Hi Jason
Here is my code for redirecting users to pages according to their level (userRole). I receive the following warning, when I browse:-
Notice: Undefined index: UserRole in C:\xampp\htdocs\Online_Site\Login.php on line 44

The "UserRole" is a column in users table in my mysql database.
The other code is created by dreamweaver. I just inserted your code with the modification according to my database
What can I do to make it work. I appreciate your assistance


mysql_select_db($database_MySQLonlineCoonetcion, $MySQLonlineCoonetcion);
$query_getCustomers = "SELECT * FROM users ORDER BY UserRole ASC";
$getCustomers = mysql_query($query_getCustomers, $MySQLonlineCoonetcion) or die(mysql_error());
$row_getCustomers = mysql_fetch_assoc($getCustomers);
$totalRows_getCustomers = mysql_num_rows($getCustomers);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
$user = $_SESSION['userRole']; //---- This is line 44
switch($user) {
case "admin":
header("Location: admin-index.php");
break;
case "client":
header("Location: clerk-index.php");
break;
case "clerk":
header("Location: client-index.php");
break;
case "guest":
header("Location: guest-index.php");
break;
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['loginbtn'])) {
// loginbtn is a hidden fieldtext has the value of 1 to ensure the login form has been submitted.
$loginUsername=$_POST['UserName'];
$password=$_POST['UserPW'];
$MM_fldUserAuthorization = $_GET['UserRole'];
$MM_redirectLoginSuccess = "/public_html/Admin/ClerkAdmin/clerk-index.php";
$MM_redirectLoginFailed = "/public_html/Login.html";
$MM_redirecttoReferrer = true;
mysql_select_db($database_MySQLonlineCoonetcion, $MySQLonlineCoonetcion);

$LoginRS__query=sprintf("SELECT UserName, UserPassword FROM users WHERE UserName=%s AND UserPassword=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $MySQLonlineCoonetcion) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
}
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...