This topic is locked
[SOLVED]

 Last Login

9/26/2007 14:26:04
PHPRunner General questions
D
dorlisa author

Hello Everyone:
Can someone help me add a last login date to my _last_login field.
I want the date of the last time the user logged in to automatically show in this field. I have searched the forum for 'last login' and it gave me one response that is slightly different than what I need.
Help,

phpnewbie

J
Jane 9/27/2007

Hi,
use AfterSuccessfulLogin event on the Events tab for this purpose.

Here is a sample code:

global $conn;

$strUpdate = "update LoginTable set _last_login=now() where UserNameField='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);



where LoginTable is your actual table name, UserNameField is your actual field name.

D
dorlisa author 9/27/2007

Hi,

use AfterSuccessfulLogin event on the Events tab for this purpose.

Here is a sample code:
where LoginTable is your actual table name, UserNameField is your actual field name.


Jane,
So is this how it should look...
global $conn;

$strUpdate = "update _members set last_login=now() where last_login='".$_SESSION["member_id"]."'";

db_exec($strUpdate,$conn);
_members is my table

last_login is the field name I want to be populated with the last date a user logged in

The UserNameField, should I use last_login?

Do I have to change the UserID field to my member_id field?

I thought "now()" set the time for today and not the last date that a user accessed the website.
Sorry for the stupid questions, but I am new to php and phprunner. I think if I can

understand how this work, I can apply it in other ways.
Thanks so much for any remedial answers you can give to the php kindergarten. :-)

Sergey Kornilov admin 9/27/2007

UserNameField is the field where you store the Username.

D
dorlisa author 9/28/2007

UserNameField is the field where you store the Username.


Hey,
Changed the username to the name of my username field, which is 'username' and nothing happens. The date is not updating...
Put the code below under AfterSuccessfulLogin, and under custom code.
global $conn;

$strUpdate = "update _members set last_login=now() where username='".$_SESSION["member_id"]."'";

db_exec($strUpdate,$conn);
Don't know what to do...

K
kjp 9/29/2007

"Global Events"

"Login page"
After successful login" then append your code below the green

"put your code..."
here is the "jane's code:

"update LoginTable set _last_login=now() where UserNameField='".$_SESSION["UserID"]."'";
In the draw below, jane's code duplicated with my own datas:

"update utilisateurs set date_last_login=now()where user_login='".$_SESSION["UserID"]."'";

My table's name is "utilisateurs"

My Last login field's name is "date_last_login"

my username field 's name is "user_login"

my userID field's name is "userID"...
If you wish to got "date" AND "time" of last login,

in phpr, go to visual editor, select list page, select YOUR logindate'field

right click/properties/select "DateTime"....

D
dorlisa author 10/1/2007

Okay kjp...
Obviously you didn't take the time to read my response, because what you posted is of absolutely no help. You just repeated what I said. If you look at my code above, you will see that I have all of the right fields, table, and code in the right spot. IT IS NOT WORKING!
My table IS '_members'

My fields ARE:

'username' IS the username field

'last_login' IS the field that I would like the last logged in date to be stored in

'member_id' IS the field that contains my members ID
Again...here is the code that is under the Events tab, under Global events, then Login page, then After Successful Login, and lastly Custom code:
global $conn;

$strUpdate = "update _members set last_login=now() where username='".$_SESSION["member_id"]."'";

db_exec($strUpdate,$conn);
Can I get someone to please tell me what is wrong.
Many, Many Thanks to the one that does...

This is frying my brain.
phpnewbie

D
dorlisa author 10/1/2007

Okay kjp...
Obviously you didn't take the time to read my response, because what you posted is of absolutely no help. You just repeated what I said. If you look at my code above, you will see that I have all of the right fields, table, and code in the right spot. IT IS NOT WORKING!
My table IS '_members'

My fields ARE:

'username' IS the username field

'last_login' IS the field that I would like the last logged in date to be stored in

'member_id' IS the field that contains my members ID
Again...here is the code that is under the Events tab, under Global events, then Login page, then After Successful Login, and lastly Custom code:
global $conn;

$strUpdate = "update _members set last_login=now() where username='".$_SESSION["member_id"]."'";

db_exec($strUpdate,$conn);
Can I get someone to please tell me what is wrong.
Many, Many Thanks to the one that does...

This is frying my brain.
phpnewbie

Alexey admin 10/1/2007

Hi,
use $_SESSION["UserID"] expression.

Don't replace UserIDhere with anything else.

D
dorlisa author 10/1/2007

Hey Alexey,
I changed it to UserID (see below) and it still does not work...
global $conn;

$strUpdate = "update _members set last_login=now() where username='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);
I have obviously did something wrong, but I have no idea what it is.
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=21805&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

Alexey admin 10/1/2007

You can publish your app on Demo account and send a link to it with problem description to support@xlinesoft.com

I'll help you to resolve it.

D
dorlisa author 10/1/2007

Hi Alexey,
I sent you an email.
I could not publish the app, because it stated that the maximum size for Demo Account is (5MB).
any suggestions...

Alexey admin 10/1/2007

Answered to your personal email address