CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 CCS: Help needed with custom login redirection~PHP

Print topic Send  topic

Author Message
George L.
Posted: 06/13/2002, 3:38 PM

I'm looking for some assistance or examples. I'm trying to redirect my user to a specific index page based on his "GroupID" session variable upon login.

I cannot seem to get my if statement to work using what I have.

1. I "tweaked CCS's CCLoginUser() function like this:
function CCLoginUser($Login, $Password)
{
$db = new clsDBDD_DEV();
$SQL = "SELECT USER_ID,USER_FIRST,SEC_ID,MULTIPLE_LOGINS,IS_ACTIVE,SESSIONS_MAX FROM USERS_DSTDB WHERE USER_NAME=" . $db->ToSQL($Login, ccsText) . " AND USER_PASS=" . $db->ToSQL(md5(crypt($Password,$Login)), ccsText);
$db->query($SQL);
$Result = $db->next_record();
if($Result)
{
CCSetSession("UserID", $db->f("USER_ID"));
CCSetSession("UserFirst", $db->f("USER_FIRST"));
CCSetSession("UserLogin", $Login);
CCSetSession("GroupID", $db->f("SEC_ID"));
$iML = $db->f("MULTIPLE_LOGINS");
$iIA = $db->f("IS_ACTIVE");

//--------------------------
// Get Login Status of user. gpl
//--------------------------

$db->query("SELECT IS_LOGGED_IN FROM LOGINSTAT_DSTDB WHERE USERNAME2USERS_DSTDB =" . $db->ToSQL(CCGetSession("UserID"), "Text"));
$db->next_record();
$iIL = $db->f("IS_LOGGED_IN");


//--------------------------
// Count number of active sessions. gpl
//--------------------------
$db->query("SELECT COUNT(SESSION_ID)AS COUNT FROM SESSIONS_DSTDB WHERE USER_NAME =". $db->ToSQL($Login, ccsText));
$db->next_record();
$iIA = $db->f("COUNT");
}
unset($db);
return $Result;
}


2. Then I have in my login page Custom Code like this. This should redirect to admin index page for any user with Group ID of 10. Anything else should go directly to the common index page.


Login Form;DoLogin Event;Custom Code

if (CCGetSession("GroupID") == "10"){
$Redirect = "/admin/index.php" . CCGetQueryString("QueryString", array("ccsForm"));;
} else {
$Redirect = "/common/index.php" . CCGetQueryString("QueryString", array("ccsForm"));;
}

3. There is also something in the login.php like this
$Redirect = "";
if($this->Validate()) {
if($this->PressedButton == "DoLogin") {
if(!CCGetEvent($this->DoLogin->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "/admin/index.php?" . CCGetQueryString("QueryString", array("ccsForm"));
}
}
} else {
$Redirect = "";
}
}


I don't know what this is for. My problem seems to stem from the fact the statement in example #3 is being evaluated rather than my custom code. Anyone have any idea why this is happening?

Tony
Posted: 06/14/2002, 6:51 AM

Hello,
try to modify $Redirect variable value directly on Login page (in the part described in #3). Or check Login button onClick event (I've created BugTrack example and I have onclick event) and try to modify $Redirect there as well.
Hope it helps.
George L.
Posted: 06/14/2002, 7:17 AM

No. THe problem is that its not working in the OnClick event. I don't know why.


I am trying to do a CCGetSession(), but the session variable I'm trying to get is not set or something.

g.
Nicole
Posted: 06/15/2002, 2:17 AM

George,
try to recreate Login from using login form builder and test does onClick event works. Just try to print anything there.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.