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