CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Login Page Redirects with UserID -Sample Code

Print topic Send  topic

Author Message
Red Storm
Posted: 01/19/2006, 5:52 AM

This may sound a little basic however I am having great difficulties.

I have a Login in page which I want each user to login into using their password and login which identifies their UserID. Once the UserID has been established at Login the person is redirected to their own user index page. I have looked and looked and read however I cannot find any sample code only redirection on things like inserting and deleting.

Is there any basic sample code available anywhere that will achieve what I am trying to do? I will have about 15 Users. Getting desperate…………..

Any help greatly appreciated as too where I could find this basic code.
mamboBROWN


Posts: 1713
Posted: 01/19/2006, 7:15 AM

Red Storm
Here is the information that I think that you are looking for: http://docs.codecharge.com/studio3/html/ProgrammingTech...irectUsers.html

Hope this helps...
View profile  Send private message
Walter Kempees
Posted: 01/19/2006, 7:51 AM

Take into account the answer from MamboBrown, then you might need to do
this:

First:
decide on a name convention for each user his page for instance Userpage01,
Userpage02 and so on.

Second, from the general login page go to a blank page displaying something
like "logging you on"
In that page you could lookup the Userid, standard function avaiable and do
a switch construction or even dumb if statements.

  
switch (CCGetUserID()) {  
case 1:  
   $Redirect = "Userpage01";  
   break;  
case 2:  
   $Redirect = "Userpage02";  
   break;  
}  

You could even dynaically build up pagenames or find any better way of doing
this, but you asked for directions.

Walter



<RedStorm@forum.codecharge (Red Storm)> schreef in bericht
news:543cf9981b2f33@news.codecharge.com...
> This may sound a little basic however I am having great difficulties.
>
> I have a Login in page which I want each user to login into using their
> password and login which identifies their UserID. Once the UserID has been
> established at Login the person is redirected to their own user index
> page. I
> have looked and looked and read however I cannot find any sample code only
> redirection on things like inserting and deleting.
>
> Is there any basic sample code available anywhere that will achieve what I
> am
> trying to do? I will have about 15 Users. Getting desperate......
>
> Any help greatly appreciated as too where I could find this basic code.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

peterr


Posts: 5971
Posted: 01/19/2006, 12:04 PM

There are various related discussions and examples here on the forums:
http://forums.codecharge.com/posts.php?post_id=68631
http://forums.codecharge.com/posts.php?post_id=53098
http://forums.codecharge.com/posts.php?post_id=48326
http://forums.codecharge.com/posts.php?post_id=47612
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Red Storm
Posted: 01/19/2006, 1:18 PM

Thank you for your responses.

Let's assume I have say 30 users. Does that mean I need to create 30 individual say index pages ie. index1, index2, index3.

Does it mean that I have too create a new "index" page each time an account is created?

Thank you for your input
peterr


Posts: 5971
Posted: 01/19/2006, 1:31 PM

I wouldn't recommend such solution, but I think that we all understood that this is what you decided to do:
Quote :
Once the UserID has been established at Login the person is redirected to their own user index page.

In most cases a good solution would be not to redirect users anywhere, but display their information on a single page. No custom code is needed for this.
You would just need to have a grid or record form (or anything else) that displays some data for the current user. Here is one way to do this: http://forums.codecharge.com/posts.php?post_id=67714
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Walter Kempees
Posted: 01/19/2006, 2:00 PM


"peterr" <peterr@forum.codecharge> schreef in bericht
news:543d0054eb2f60@news.codecharge.com...
>I wouldn't recommend such solution, but I think that we all understood that
>this
> is what you decided to do:

Yes that's what I understood.
From the links by peterr there is an example on redirecting according to
GroupID, which in combination with Peterr's previous suggestion, would be my
way to go.

Visiomart

Posts: 13
Posted: 01/20/2006, 4:54 PM

Red Storm.

Let me suggest this out..
"Once the UserID has been established at Login the person is redirected to their own user index page"
Now since the session keeps the userID why don't you just redirect these users to a general page appended with their userID ie from session to be the main parameter here..

It's very simple. let me give you an overview.

Assuming you want each of these users to view info froma db or tomake modification as well insertion of data records into table you append the record- datasource to receive paramater or display informations according to the parameter obatined from the session..

for instance user_id of these users from table <users> beign used as a login table in the project automaticallu selecting the user_id as the UserID will be the session parameter that uniquely identify this user. okay now in the datsource you select user_id equal to UserID from session not url. Using this you append the parameter from session instead of url.

NOTE: if you show userId in parameters it's not safe and henceforth users do not even need to login afterall since anyone can just come online adnd type ...index.php?user_id=xxxxx and obtain these users information..
have a nice day i hope this solves your problem.
_________________
Don Capone
View profile  Send private message
Red Storm
Posted: 01/28/2006, 4:00 PM

I have followed (to hte best of my abilities which could be the issue here!) the advice provided to date.

As a test I have added the following code to my login page.

<?php
//BindEvents Method @1-788B314F
function BindEvents()
{
global $Login;
global $CCSEvents;
$Login->Button_DoLogin->CCSEvents["OnClick"] = "Login_Button_DoLogin_OnClick";
$CCSEvents["BeforeShow"] = "Page_BeforeShow";
}
//End BindEvents Method

//Login_Button_DoLogin_OnClick @3-9DE63FBA
function Login_Button_DoLogin_OnClick(& $sender)
{
$Login_Button_DoLogin_OnClick = true;
$Component = & $sender;
$Container = CCGetParentContainer($sender);
global $Login; //Compatibility
//End Login_Button_DoLogin_OnClick

//Login @4-AF70F5F5
global $CCSLocales;
global $Login;
if(!CCLoginUser($Container->login->GetValue(), $Container->password->GetValue()))
{
$Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
$Container->password->SetValue("");
$Login_Button_DoLogin_OnClick = false;
}
else
{
global $Redirect;
$Redirect = CCGetParam("rel_link", $Redirect);
$Login_Button_DoLogin_OnClick = true;
}
//End Login

//Custom Code @7-2A29BDB7
// -------------------------
function Login_DoLogin_OnClick(& $sender) {

if ($Login_DoLogin_OnClick == true) {
$db = new clsDBConnection1();
CCSetSession("company_name", CCDLookUp("company_name","users","user_id=".$db->ToSQL(CCGetUserID(),ccsInteger), $db) );
$db->close();
}

}

// -------------------------
//End Custom Code

//Close Login_Button_DoLogin_OnClick @3-0EB5DCFE
return $Login_Button_DoLogin_OnClick;
}
//End Close Login_Button_DoLogin_OnClick

//Page_BeforeShow @1-890C5EB0
function Page_BeforeShow(& $sender)
{
$Page_BeforeShow = true;
$Component = & $sender;
$Container = CCGetParentContainer($sender);
global $login1; //Compatibility
//End Page_BeforeShow

//Custom Code @8-2A29BDB7

if(CCGetSession("user_id") == "")
{
header("Location: login.php");
}
elseif (CCGetSession("user_id") == 1)
{
header("Location: client/index1.php");
}
elseif(CCGetSession("user_id") == 2)
{
header("Location: client/index2.php");
}
//End Custom Code

//Close Page_BeforeShow @1-4BC230CD
return $Page_BeforeShow;
}
//End Close Page_BeforeShow

?>


I have setup index1.php and index2.php as a test page to see if the redirects are correct. They do not appear to be working. I have 3 different user_id's that I use and each time I get sent back to the same page. In other words it is not identifying my user_id when logging on. Could anyone please suggest the problem with the code as posted above. I am sure it is easy however I am missing sometihng fundamental.

Thank you all.
Damian Hupfeld
Posted: 01/29/2006, 3:00 AM

Red Storm,

The easiest way may not be what you are trying to do here. You specified
that each person needs to get their own unique login page. Others have
alluded that the easiest approach is to direct everyone to the SAME login
page but only display that users data.

How do you do this?

On Login a number of session values are set including the UserID. This can
be retrieved with CCGetSession("UserID").

On your index.php page you want to create one or more grids. In the Data
Source go to the Where statements and add a new parameter of type session
where your userid field name (whatever it is called) equals UserID (spelt
exactly that way).

This will then only display recors in that grid that contain that UserID in
the nominated field.

You could display all sorts of customised data -

Update your Details
Your Documents
Your Tasks
Your anything else you need to display - so long as somewhere in the table
you have the users UserID value.

Damian



<RedStorm@forum.codecharge (Red Storm)> wrote in message
news:543dc05b7d0a9b@news.codecharge.com...
>I have followed (to hte best of my abilities which could be the issue
>here!) the
> advice provided to date.
>
> As a test I have added the following code to my login page.
>
> <?php
> //BindEvents Method @1-788B314F
> function BindEvents()
> {
> global $Login;
> global $CCSEvents;
> $Login->Button_DoLogin->CCSEvents["OnClick"] =
> "Login_Button_DoLogin_OnClick";
> $CCSEvents["BeforeShow"] = "Page_BeforeShow";
> }
> //End BindEvents Method
>
> //Login_Button_DoLogin_OnClick @3-9DE63FBA
> function Login_Button_DoLogin_OnClick(& $sender)
> {
> $Login_Button_DoLogin_OnClick = true;
> $Component = & $sender;
> $Container = CCGetParentContainer($sender);
> global $Login; //Compatibility
> //End Login_Button_DoLogin_OnClick
>
> //Login @4-AF70F5F5
> global $CCSLocales;
> global $Login;
> if(!CCLoginUser($Container->login->GetValue(),
> $Container->password->GetValue()))
> {
>
> $Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
> $Container->password->SetValue("");
> $Login_Button_DoLogin_OnClick = false;
> }
> else
> {
> global $Redirect;
> $Redirect = CCGetParam("rel_link", $Redirect);
> $Login_Button_DoLogin_OnClick = true;
> }
> //End Login
>
> //Custom Code @7-2A29BDB7
> // -------------------------
> function Login_DoLogin_OnClick(& $sender) {
>
> if ($Login_DoLogin_OnClick == true) {
> $db = new clsDBConnection1();
> CCSetSession("company_name",
> CCDLookUp("company_name","users","user_id=".$db->ToSQL(CCGetUserID(),ccsInteger),
> $db) );
> $db->close();
> }
>
> }
>
> // -------------------------
> //End Custom Code
>
> //Close Login_Button_DoLogin_OnClick @3-0EB5DCFE
> return $Login_Button_DoLogin_OnClick;
> }
> //End Close Login_Button_DoLogin_OnClick
>
> //Page_BeforeShow @1-890C5EB0
> function Page_BeforeShow(& $sender)
> {
> $Page_BeforeShow = true;
> $Component = & $sender;
> $Container = CCGetParentContainer($sender);
> global $login1; //Compatibility
> //End Page_BeforeShow
>
> //Custom Code @8-2A29BDB7
>
> if(CCGetSession("user_id") == "")
> {
> header("Location: login.php");
> }
> elseif (CCGetSession("user_id") == 1)
> {
> header("Location: client/index1.php");
> }
> elseif(CCGetSession("user_id") == 2)
> {
> header("Location: client/index2.php");
> }
> //End Custom Code
>
> //Close Page_BeforeShow @1-4BC230CD
> return $Page_BeforeShow;
> }
> //End Close Page_BeforeShow
>
> ?>
>
>
> I have setup index1.php and index2.php as a test page to see if the
> redirects
> are correct. They do not appear to be working. I have 3 different
> user_id's
> that I use and each time I get sent back to the same page. In other words
> it is
> not identifying my user_id when logging on. Could anyone please suggest
> the
> problem with the code as posted above. I am sure it is easy however I am
> missing sometihng fundamental.
>
> Thank you all.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Red Storm
Posted: 01/29/2006, 5:03 AM

Thanks Damian,

I think I finally understand the issue. You have explained the issue well. Thank you. Will try and see how it goes.

RS
Red Storm
Posted: 02/06/2006, 4:23 AM

Further to the last posting I have taken your advice and am trying to direct everyone to the samelogin page but only display that particular users data.

This is the login_events.php

<?php
//BindEvents Method @1-096E3C73
function BindEvents()
{
global $Login;
$Login->Button_DoLogin->CCSEvents["OnClick"] = "Login_Button_DoLogin_OnClick";
}
//End BindEvents Method

//Login_Button_DoLogin_OnClick @3-9DE63FBA
function Login_Button_DoLogin_OnClick(& $sender)
{
$Login_Button_DoLogin_OnClick = true;
$Component = & $sender;
$Container = CCGetParentContainer($sender);
global $Login; //Compatibility
//End Login_Button_DoLogin_OnClick

//Login @4-AF70F5F5
global $CCSLocales;
global $Login;
if(!CCLoginUser($Container->login->GetValue(), $Container->password->GetValue()))
{
$Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
$Container->password->SetValue("");
$Login_Button_DoLogin_OnClick = false;
}
else
{
global $Redirect;
$Redirect = CCGetParam("ret_link", $Redirect);
$Login_Button_DoLogin_OnClick = true;
}
//End Login

//Custom Code @7-2A29BDB7
// -------------------------

if ($Login_Button_DoLogin_OnClick) {
$db = new clsDBcrcgroup_audit();
$SQL = "SELECT * FROM `user` WHERE user_id=" . CCGetUserID();
$db->query($SQL);
$Result = $db->next_record();
if($Result)
{
CCSetSession("UserID", $db->f("user_id"));
CCSetSession("UserLogin", $login);
CCSetSession("GroupID", $db->f("user_level"));
}
$db->close();
}

// -------------------------
//End Custom Code


//Close Login_Button_DoLogin_OnClick @3-0EB5DCFE
return $Login_Button_DoLogin_OnClick;
}
//End Close Login_Button_DoLogin_OnClick


?>

After creating this code I have viewed the example at
http://forums.codecharge.com/posts.php?post_id=67714

I have followed the instructions fully and believe I have executed this correctly however I do not get any data appearing in the Grid when running it as a live page. As such I beleive that maybe the Login code is incorrect.

Once again any help or guidance would be appreciated.
Red Storm
Posted: 02/06/2006, 6:56 AM

OK Finally got it right. All working fine.

THANK YOU ALL FOR YOUR ASSISTANCE
roders

Posts: 127
Posted: 02/06/2006, 7:43 AM

This could be a solution to mine as well but all i have is a table which is a message history it acts the same as an inbox, following these i found out that you can use your sql to make it work but all i need is how to keep the session.
I got lucky once while searching through the documentation but now i can't find it anymore.
What i fink would be easier for is to store the session and in the sql is to add in the where clause "where userid=useridsession".
Anyidea?
_________________
roders
View profile  Send private message

Add new topic Subscribe to topic   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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