This topic is locked

Counter of people that logim

5/26/2008 3:14:35 AM
PHPRunner General questions
S
shoppy author

Hi all,
My clients can login to check there documents and other stuff.

Now I like to know who actualy does this.
So is it possible to get a counter or something that lists the people that login?

Maybe also when (date/time) and how many times?
Thanks,
John

J
Jane 5/26/2008

John,
you can save timestamp of login and increase counter of logins in the AfterSuccessfulLogin event.

Here is a sample:

global $conn;

$strUpdate = "update TableName set DateTimeOfLogin=Now() and NumbersOfLogin=NumbersOfLogin+1 where UserName='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);



where DateTimeOfLogin, NumbersOfLogin and UserName are your actual field names, TableName is your actual table name.

M
mickmouser 5/27/2008

Hello: The following is already in my "after successful log-in" event. Where do I add the code you provided; so I will be able to see how many are logged in, etc. Thank you, Janice
global $conn;
$tmpSQL="select from users where Email='" . $username . "' and Password='" . $password . "'";

$rs = db_query($tmpSQL,$conn);

if($data1 = db_fetch_array($rs))

{

$begindate=$data1["Beginpay"];

$enddate=$data1["Endpay"];

$_SESSION["ppuid"]=$data1["ID"];

if($data1["Paypal"]==0)

{

header("Location: login.php?a=pp0");

exit();

}

if(strtotime($enddate)-strtotime($begindate)!=0 && (strtotime($enddate)-strtotime($begindate))/(60
60*24)<0)

{

header("Location: login.php?a=pp1");

exit();

}

}

J
Jane 5/27/2008

Hi,
add this code in the beginning of your code:

global $conn;

$strUpdate = "update TableName set DateTimeOfLogin=Now() and NumbersOfLogin=NumbersOfLogin+1 where UserName='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);
$tmpSQL="select * from users where Email='" . $username . "' and Password='" . $password . "'";

$rs = db_query($tmpSQL,$conn);

...

S
shoppy author 5/27/2008

Sorry Jane,
Don't get to work.
I put it just as you said in the "after successful log-in" event, gave the table _klant the extra fields "DateTimeOfLogin" and "NumbersOfLogin".

Now I don't know what to put in 'Username' and in 'UserID'.
So I played with Name and also with clientID. These are the fields in _klant.
But it doesn't count anything.
John

J
Jane 5/28/2008

John,
replace Username with your actual field name where login name is stored. Don't change $_SESSION["UserID"] variable.

global $conn;

$strUpdate = "update TableName set DateTimeOfLogin=Now(), NumbersOfLogin=NumbersOfLogin+1 where UserName='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);

S
shoppy author 5/28/2008

John,

replace Username with your actual field name where login name is stored. Don't change $_SESSION["UserID"] variable.


Hi Jane,
It doesn't work.
I only replaced "TableName" in _klant and "UserName" in Inlognaam. But it doesn't count anything.
I made a seperate View from _klant called LoginMonitor to view what happenes in the fields NumberOfLogin and DateTimeOfLogin (witch are in _klant) but it just gives all the names without output in the two fieldnames.

S
shoppy author 5/28/2008

I tried to post the whole thing in the Demo account but it is bigger then 5 MB so that didn't work as well.
How to go about this?
regards,
John

J
Jane 5/28/2008

John,
download and install latest PHPRunner update:

http://www.asprunner.com/files/phprunner-setup.zip
Then rebuild your project and upload it to the Demo Account again. There is no 5MB restriction in the last PHPRunner update.

S
shoppy author 5/28/2008

My dear Jane,
The thing has an maximum of 10MB !!!!!

M
mickmouser 5/28/2008

Hello Again: So after all the comments back and forth, what code do I put where to make the count thing work? The following is already in my "after successful log-in" event. Where do I add the code you provided; so I will be able to see how many are logged in, etc. Thank you, Janice
global $conn;
$tmpSQL="select from users where Email='" . $username . "' and Password='" . $password . "'";

$rs = db_query($tmpSQL,$conn);

if($data1 = db_fetch_array($rs))

{

$begindate=$data1["Beginpay"];

$enddate=$data1["Endpay"];

$_SESSION["ppuid"]=$data1["ID"];

if($data1["Paypal"]==0)

{

header("Location: login.php?a=pp0");

exit();

}

if(strtotime($enddate)-strtotime($begindate)!=0 && (strtotime($enddate)-strtotime($begindate))/(60
60*24)<0)

{

header("Location: login.php?a=pp1");

exit();

}

}

J
Jane 5/29/2008

mickmouser,
add this code in the beginning of your code:

global $conn;

$strUpdate = "update TableName set DateTimeOfLogin=Now() and NumbersOfLogin=NumbersOfLogin+1 where UserName='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);
$tmpSQL="select * from users where Email='" . $username . "' and Password='" . $password . "'";

$rs = db_query($tmpSQL,$conn);

...


John,
post your actual code here.

S
shoppy author 5/29/2008

Hi Jane,
Is this what you mean?
global $conn;

$strUpdate = "update _klant set DateTimeOfLogin=Now() and NumberOfLogin=NumberOfLogin+1 where KlantID='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);

J
Jane 5/29/2008

Here is the correct code:

global $conn;

$strUpdate = "update _klant set DateTimeOfLogin=Now(),NumberOfLogin=NumberOfLogin+1 where KlantID='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);

S
shoppy author 5/29/2008

Here is the correct code:



Sorry Jane,
I just don't get it to work.
I just let this thing be for a while.
I would like you to answer my other question about the 'CV' file.
regards
John