close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Storing last user login date

Thread began 7/20/2011 2:40 am by info266692 | Last modified 7/25/2011 10:50 am by Ray Borduin | 3962 views | 7 replies |

info266692

Storing last user login date

I have searched throughout the URSP Forum to find out how you can store the last login date when a User complete the login page; and I couldn’t find any relevant information.

I have created a column in the users table to store the login date (login_date, type datetime) is this the right attribute for storing date and time in SQL?

I also made countless attempts into the page users_LogIn.php by inserting various system to store the last user login date in the column login_date of the users table, but nothing ever worked.

Can you help me in resolving this issue? My database skills are a bit more than basic and my coding experience is slightly more than of a novice.

I found Web Assist extensions quite liberating by making accessible PHP scripts and creating new dimensions in web design beyond the plain HTML and Java Scripts. Thanks for your great extensions.

Alfredo

Sign in to reply to this post

Jason ByrnesWebAssist

This sort of modification is not supported in the Solution packs, I can give you steps to follow, but cant really offer more help if you are not able to get this working.


first, open the bindings panel and expand the session collection, make sure there is a session in the bindings panel named UserID, if its not there, click the plus button , selct Session Variable and name it UserID to createt the binding.

now, on the login page, locate the two lines that redirect to the users_Profile page:

php:
"successRedirect" => "users_Profile.php",




and change them both to:

php:
"successRedirect" => "",




Now go to the server behaviors panel and click the plus button, select Data Assist, updare record, single record Update

in the update record dialog box, select the users table, set the key column to UserID

click the lightning bolt next to value and selcet the UserID session variable binding.

set the redirect to go to the users_Profile.php

on the second step, select your login_date column and enter the following code for the value:
[php]
<?php echo (date("Y-m-d h:m:s")); ?>
[php]


in the code, you will need to move the update record code so that it comes after the login user code.

Sign in to reply to this post

info266692

Storing last user login date

Dear Jason,

I have made those changes, following your directions, to the user_LogIn.php page and I'm getting an error "Incorrect datetime value ....". In actual fact the page showing the error displays the right date and time (I had to change the low cases to capital in your code snippet "[php]<?php echo (date("Y-m-d h:m:s")); ?>[php]" to "[php]<?php echo (date("Y-M-D h:m:s")); ?>[php]".

I figure the error is due to the fact that the Update Record Code is not updating the database or maybe is not positioned properly after the login user code.

I'm designing a web site for a blind person who has a number of clients to administer and check out if they make use of the site. I know that is possible to create some Clients monitoring systems with other tables and query pages but this will complicate the Administration area. I really would like to keep it simple and record the date the Client has logged in.

I understand that this bit of coding is not supported by WA with URSP, however throughout this forum there many bits of codes suggested in other applications which goes well behind what is provided in the packages.

Can you help to find a solution to this error?
Thank you again

Sign in to reply to this post

Ray BorduinWebAssist

In this case the case is significant and would cause it to break with your changes.

The issue is probably that it should have originally been 'Y-m-d h:n:s'

With your current settings it would be trying to set the date to: '2011-Jul-21 12:21:00', which would give a syntax error. See the meaning and case of the date settings on the page:

function.date.php

Try with the correct date string and let me know if you still get errors. If so, attach a current version of the page to your thread and I'll see if I can suggest a fix.

Sign in to reply to this post

info266692

Dear Ray,

I have reverted to the code [php]<?php echo (date("Y-m-d h:m:s")); ?>[php] and i'm still getting this error: "Incorrect datetime value: '[php]2011-07-22 10:07:30[php]' for column 'login_date' at row 1".

The date is correct but it doesn't want to be registered in the database.

I have included a compressed file of the user_LogIn.php page for you to have a look at it.

Currently the in the column login_date, type datetime of the database there are dates stored from the previous version of the web site, shall I flush them away?

I'm testing the site on my local server in the Sydney time zone (Apache, PHP5.2.3, SQL) while the web host is located in the US via Perth in Australia. It may be possible that the incorrect datetime issue has to do with different time zones and daylight saving?

Thanks again for your assistance.
Alfredo from Oz

Attached Files
users_LogIn.zip
Sign in to reply to this post

Ray BorduinWebAssist

You should not be including the "[php]" references.

You should be using the value: <?php echo (date("Y-m-d h:n:s")); ?>

(notice also the 'n' should be used for the minutes 'm' is the month)

Sign in to reply to this post

info266692

Storing last user login date

Dear Ray,
Whoops; you can see that I'm a bit green with PHP codings by the errors I'm making.

I did make those changes as you have suggested and now i'm getting a different error with the user_LogIn.php page "The login information provided is not valid. Please try again.".

This is the verification message in the Email Address field. I did shift the Update Single Record in the Server Behaviors right to the bottom of all the login codes and i'm still getting this error.

Do you have any other suggestions in how i can get around this error?

What about if we use the clients/index.php page to update the datetime record? However in this page there are no Form Fields to attach the Update Single Record coding.

Thanks again for your assistance.
Alfredo

Sign in to reply to this post

Ray BorduinWebAssist

I think the authenticate user server behavior may require a success field, so adding it to the client index page may be a better solution.

You wouldn't need to use a form field. You could just add the update server behavior and set the updated field value to: <?php echo (date("Y-m-d h:n:s")); ?>

There is no requirement to have or use a form when updating a record.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...