PHP based on login time to achieve multiple logons per day only one function

Source: Internet
Author: User
This article mainly introduces PHP based on the login time to realize the implementation of multiple login points once a day function, suitable for membership system integration function, involving PHP time to judge and database related operations skills, the need for friends can refer to the next

This article describes PHP based on the login time to achieve multiple logons per day only once the function. Share to everyone for your reference, as follows:

On the internet to find a lot of cases, feel like, some of the more cumbersome, I tried a bit, how to achieve this function

To do this, I added a field logintime to the data table, indicating the last logon time, and then using 0 minutes and 0 seconds of the day to compare with the last logon time, if the last logon time was greater than the time point, If the last logon time is less than this point in time, it means the first sign-in, adding points

On the code:

Determine if the first login//Last login time of the day $lastlogintime = $userinfo [' Logintime '];//day of zero 0 minutes 0 seconds $today = strtotime (Date (' y-m-d ')); if ( $lastLogintime < $today) {  //The first sign in the day adds points (associated updates)  //NOTE: You need to pass two IDs when updating data using correlation  $data [' id '] = $userinfo [' Id '];  $data [' userinfo '] = Array (    ' points ' = = $userinfo [' points '] + C (' LOGIN ')  ;  $user->relation (True)->where (array (' id ' = = $userinfo [' id ']))->save ($data);}

Note that you also need to modify the logon time:

Update login time and login Ip$updatedata = Array (  ' id ' = = $userinfo [' id '],  ' userinfo ' = = Array (    ' logintime ' = Time (),    ' loginip ' = GetIP (),  ), $user->relation (True)->where (array (' id ' = = $userinfo [' id ']) ->save ($updateData);

This will enable this function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.