SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Demote user access if not login with in 3 dats

    i have this script where i want it to demote anyone who hasnt logged in with the last 3 days to be demoted and it only to demote a certain rank down

    this is my code

    PHP Code:
        require("dbconnect.php");
        
    $gQuery="SELECT * FROM members";
        echo 
    $gQuery;
        
    //excute the query
        
    $rs=mysqli_query($con,$gQuery);
        if(!
    $rs)
        {
            
    $dbError="Error:Failed to executing query".mysqli_error($con);
        }
        else
        {
            
    $count=$rs->num_rows;
            if(
    $count>0)
            {
                while(
    $data=$rs->fetch_assoc())
                {
                        
    $username=$data['username'];
                        
    $LastedLogin=$data['LastedLogin'];
                        
    $dslcalcDSLCode($LastedLogin);
                }
            }
        }
        function 
    calcDSLCode($LastedLogin)
        {
            
    $today=date("Ymd");
            require(
    "dbconnect.php");
            
    $Query="SELECT TO_DAYS($today)-TO_DAYS($LastedLogin) FROM members";
            echo 
    $Query;
            
    $result mysqli_query($con,$Query);
            if(!
    $result)
            {
                 echo 
    "Error:".mysqli_error($con);
            }    
            else
            {    
                
    $days mysqli_fetch_array($result);
                if(
    $days>=3)
                {
                    
    $gdQuery="Update Members set rank=rank-2 WHERE disable='1'";
                    echo 
    "<br/><br/>".$gdQuery."";
                    
    $rs=mysqli_query($con,$gdQuery);
                    if(!
    $rs)
                    {
                        echo 
    "Cannot demote $username because:".mysqli_error($con);
                    }
                    else
                    {
                        echo 
    "People who have not Logged in with in 3 days will be demoted";
                    }
                }
                
    //
            
    }
        } 
    Thanks if anyone can help me fix this it will be good thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to modify this query so that the number of days since last logged in is associated with your member. How do you differentiate between users ?
    PHP Code:
    $Query="SELECT TO_DAYS($today)-TO_DAYS($LastedLogin) FROM members"
    Does calcDSLCode() update just one member ?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i want it so it Updates all members


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •