How to limit how often a user can update a mysql value to a database

后端 未结 4 2041
我在风中等你
我在风中等你 2021-01-24 16:51

I have a field on my website, which updates a value in my mysql database. I want to make it so the user can only update the value every 3 days. How would I go about doing this?<

4条回答
  •  情歌与酒
    2021-01-24 17:37

    Create new row into db (last_update) type= data

    //return to sql last_update (select db ...)
    
    $current_Data = date ('Y-m-d');
    $current_Data_time = strtotime ($current_Data); //convert data to time
    $last_update_p3 = strtotime ("+3day", strtotime($last_update));
    $last_update_p3 = strtotime ($last_update_p3);//convert data to time
    
    if($current_Data_time <=$last_update_p3)
    {
     $sql = $con->query("UPDATE users SET HWID = '{$UpdateHWID}' , last_update='{$current_Data}'  where UserID = $User");
    //update last data with current date 
    }
    else
    {
    //It has not gone three days 
    }
    

提交回复
热议问题