John Blood
|
| Posted: 05/03/2002, 4:07 PM |
|
Hello everyone!
I'm nearly finished with my biggest project yet and I've got just two sticking points left. This post addresses sticking point #1.
I discovered the Help files beyond the various tutorials and have been delighted with what I've been learning. What a 'hidden' treasure!
I'd like to modify the Custom Login PHP script from the Help file so that:
1. User logs in with username/password
2. User's primary key (fieldname = LIN_ID) is selected from database
3. Login script redirects as such:
if SecurityLevel for LIN_ID = 3, redirect user to AdminMenu.php
else
if SecurityLevel for LIN_ID = 2, redirect user to their own record editing page in the form LINeeRecordEntry.php?LIN_ID&
This is my first real journey into complicated PHP/SQL. Can someone check this script for me and let me know where I'm going wrong? The result I get from this is redirecting me to the URL "LINeeRecordEntry.php?\&". Not quite what I need.
Here's the script for a kind reviewer:
$sLogin = get_param("Login");
$sPassword = get_param("Password");
$db->query("SELECT LIN_ID,SecurityLevel FROM LINRoster WHERE Username =" . tosql($sLogin, "Text") . " AND Password=" . tosql($sPassword, "Text"));
$is_passed = $db->next_record();
if($is_passed)
{
//-------------------------------
// Login and password passed
//-------------------------------
set_session("UserID", $db->f("LIN_ID"));
set_session("UserRights", $db->f("SecurityLevel"));
if (get_session("UserRights") == 3)
{
header("Location: AdminMenu.php");
exit;
}
else
{
header("Location: LINeeRecordEntry.php" . "?" . get_session($UserID) . "\&");
exit;
}
}
else
{
$sLoginErr = "Login or Password is incorrect.";
}
Again, thank you for your kind help. I have one more question (that I know about) that I'll post separately.
John
jblood@beholdlearning.com
|
|
|
 |
John K. Blood
|
| Posted: 05/03/2002, 8:46 PM |
|
Hi All!
I got it working! The code is below for those who are interested:
$sLogin = get_param("Login");
$sPassword = get_param("Password");
$db->query("SELECT LIN_ID,SecurityLevel FROM LINRoster WHERE Username =" . tosql($sLogin, "Text") . " AND Password=" . tosql($sPassword, "Text"));
$is_passed = $db->next_record();
if($is_passed)
{
//-------------------------------
// Login and password passed
//-------------------------------
set_session("UserID", $db->f("LIN_ID"));
set_session("UserRights", $db->f("SecurityLevel"));
if (get_session("UserRights") == 3)
{
header("Location: AdminMenu.php");
exit;
}
else
{
header("Location: LINeeRecordEntry.php" . "?" . "LIN_ID=" . get_session("UserID"));
exit;
}
}
else
{
$sLoginErr = "Login or Password is incorrect.";
}
|
|
|
 |
|