close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Store and Update The Number of Times Registered Users Login to access contents.

Thread begun 7/10/2012 6:34 pm by Mysite07430650 | Last modified 7/17/2012 12:10 pm by Mysite07430650 | 4962 views | 10 replies |

Mysite07430650

Store and Update The Number of Times Registered Users Login to access contents.

Hello everyone,

I think what am after is possible but I need help with the various steps involved. I have SecurityAssist created registration pages which includes, Login, Logout, Registration, ForgottenPaswword and Userupdate pages. I know what I need to do requires me to add session variables via SecurityAssist Authenticate User dialogue box, but I need help with the coding and steps required as previously mentioned.

Is there a way to record, store and update the amount of times and (last time or date) a user logs in to access contents in their home or profile page?

What I need is best illustrated with an example: User A logs in to access content on his home or profile page 6 times a day, while User B logs in to access content on her home or profile page perhaps 2 time a day. The Same applied to User C, User D, etc,

Would I need to create two columns in the datebase User table, say Column 1 = UserLoginCount, and Column 2 = UserLoggedinLast.

Where Column 1 = UserLoginCount stores integer values that is incremented as the user logs in and Column 2 = UserLoggedinLast stores the dates the user last logged. In that scenario, day 1 the user logs in 6 times and revisits on day 2 and logs in 3 times. The user table should show the user has logged in on those many times on the respective days.

Then I want to be able to display the data in a recordset, showing the number of times users are logged in to access contents on their home or profile page, and corresponding date when they last logged in.

I searched the forum and am mindful that it can be done, but I cannot find anything concrete on the steps required to make it happen.

I appreciate any help that points me in the right direction.

Thank you in advance.

Sign in to reply to this post

Jason ByrnesWebAssist

you will need to add the count and logged in date columns to the users table.

edit the Authenticate user behavior on the login page so that it does not redirect. Make not of the name of the session that is created whith the users ID

create a recordset to lookup the users record in the the database, see the recordset on the profile page for details

add a Update record behavior to update the users table. for the Key Column value, use the users ID session variable.

For the login count, use the login count binding from the recordset. the binding code will look like:
<?php echo($_row_recordsetName['LoginCount']) ?>

add + 1 to that:
<?php echo($_row_recordsetName['LoginCount'] + 1) ?>

fro the login date, use the following code:
<?php echo(date(Y-m-d h:m:s)); ?>

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  you will need to add the count and logged in date columns to the users table.

edit the Authenticate user behavior on the login page so that it does not redirect. Make not of the name of the session that is created whith the users ID

create a recordset to lookup the users record in the the database, see the recordset on the profile page for details

add a Update record behavior to update the users table. for the Key Column value, use the users ID session variable.

For the login count, use the login count binding from the recordset. the binding code will look like:
<?php echo($_row_recordsetName['LoginCount']) ?>

add + 1 to that:
<?php echo($_row_recordsetName['LoginCount'] + 1) ?>

fro the login date, use the following code:
<?php echo(date(Y-m-d h:m:s)); ?>  



Hello Jason,

Thanks for responding to my thread. I just wanted to clarify few things regarding the solution you've provided.

I have created LoginCount and LoginDate columns in the User table. The LoginCount is set to INT and the LoginDate is set to DateTime respectively in the user table. I hope this is correct.

Do I need to define session values on the home page of the user as in WA Set Session Value (LoginCount) and WA Set Session Value (LoginDate), to be used in conjuction with the recordset?

I have also removed the unchecked the redirect function in both SecurityAssist Authenticate User dialogue box, and have also added the both created column names to the Session Values list.

Does LoginCount and LoginDate need to have initial default values either in the user table or server binding?

I have created a recordset for the homepage of the table users. Is that correct or am I supposed to create the recordset in the Login page?

Will I need to add the update record behaviour in the Login page or the Home page of the users?

Lastly, would these codes:

<?php echo($_row_recordsetName['LoginCount']) ?>

add + 1 to that:
<?php echo($_row_recordsetName['LoginCount'] + 1) ?>

fro the login date, use the following code:
<?php echo(date(Y-m-d h:m:s)); ?>[/QUOTE]

be added to update single record General Tab or Bindings?

Thanks for your help. Appreciated.

Sign in to reply to this post

Mysite07430650

Hello Jason,

I am getting parsing error message which you can see in the screen capture. The page affected is the registered users home or profile page, which is currently protected by SecurityAssist with Authentication logged into the user table.

I have also included a screen capture of part of the code affected and evidently this has something to do with the way I have implemented the server behaviour update record.

I have also attached a zip file of the webassist codes for the page.

Please advise on how I can correct this error.

Thank you.

Sign in to reply to this post

Mysite07430650

Originally Said By: Mysite07430650
  Hello Jason,

I am getting parsing error message which you can see in the screen capture. The page affected is the registered users home or profile page, which is currently protected by SecurityAssist with Authentication logged into the user table.

I have also included a screen capture of part of the code affected and evidently this has something to do with the way I have implemented the server behaviour update record.

I have also attached a zip file of the webassist codes for the page.

Please advise on how I can correct this error.

Thank you.  




I worked out the error I had earlier experienced was due to having <?php echo(date(Y-m-d h:m:s)); ?> instead of <?php echo (date("Y-m-d h:n:s")); ?>

I have been able to login and access the Users Home or Profile page.

The Update record code is within the Login Page and the following was applied:

DataAssist: Update Single Record

General Tab

Trigger: any form post
Database connection set to Registered Users Table.
Key Column: UserID
Value: <?php echo $_SESSION['SecurityAssist_UserID']; ?>

Bindings:

Column: LoginCount
Type: Numeric
Value: <?php echo $row_rsLoggeduser['LoginCount'] +1; ?>

Column: LoginDate
Type: Date
Value: <?php echo (date("Y-m-d h:n:s")); ?>

The Update Record is below the user login, therefore I am able to login and upon login success be directed to the Users Home or Profile page.

Assuming I have done the right thing, then I really don't know why the LoginCount and LoginDate are not being updated in the database user table.

Please help!

Sign in to reply to this post

Jason ByrnesWebAssist

Send a copy of the page please so i can see the code.

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  Send a copy of the page please so i can see the code.  



Hello Jason,

Thank you for responding to my messages. I have tried to make several changes to the file but on the whole it is pretty much what I have earlier.

Sign in to reply to this post

Jason ByrnesWebAssist

The login behavior is set to redirect to the index.php page on login success, this redirect will happen before the update record behavior can take place.

You need to edit the authenticate user behavior and set it to not go anywhere on login success.

add the redirect to the index.php page to the update record behavior.

Sign in to reply to this post

Mysite07430650

Originally Said By: Jason Byrnes
  The login behavior is set to redirect to the index.php page on login success, this redirect will happen before the update record behavior can take place.

You need to edit the authenticate user behavior and set it to not go anywhere on login success.

add the redirect to the index.php page to the update record behavior.  



Thanks Jason for the reply.

I did get rid of the redirect to index.php as advised and this served to update the LoginCount Column and LoginDate column respectively. The only problem is that the LoginCount value is static and no matter how many times I log in, logout and repeated all over again, the LoginCount yields a static value of 1 and does not reflect the number of times a user logs in.
In essence, this code <?php echo $row_rsLoggeduser['LoginCount']+1; ?> outputs the static value of 1 in the LoginCount Column. If it is changed to say 10 i.e., <?php echo $row_rsLoggeduser['LoginCount']+10; ?>, an output value of 10 is registered in the LoginCount Column of the user table no matter how many times a person logs in.

I was wondering if the LoginCount column needs to be defined or set so that it automatically increments by a value of 1 every time registered users log in. If that is indeed the case, how do I go about it and more precisely can you please let me know the code needed to achieve this.

Thank you for your help.

Sign in to reply to this post

Jason ByrnesWebAssist

the rsLoggeduser recordset is not returning the correct result.

you have it set to filter the user id column on the userID session variable, but the name of the session created by security assist is:

SecurityAssist_UserID


You need to use that session in the recordset instead.

Sign in to reply to this post
loading

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...