i have a login system where the user logs in but now what i want it to do is 3 things i want to intergrate a mia (missing in action script so the user doesnt have to login) and the other 2 things are if they havnt logged in for 3 days demote them and if they still havnt logged in then disable them automatically this is what my login system has already.

PHP Code:
<?php
    session_start
();
    
$msg_pass="";
    
$msg_user="";
    
error_reporting(E_ALL);
    
$username=$_POST['username'];
    
$password=$_POST['password'];
    if(
$username && $password)
    {
        
//include database        
        
include("dbconnect.inc");
        
$cQuery="SELECT * FROM members WHERE username='".$username."'";
        
//echo $cQuery;
        
$rs=mysqli_query($con,$cQuery);
        if(!
$rs)
        {
            echo 
"Unable to excute the query:".mysqli_connect_errno($con);
        }
        else
        {
                
$count=mysqli_num_rows($rs);
                if(
$count>0)
                {
                    
$data=mysqli_fetch_assoc($rs);
                    if(
$data['password']=$password)
                    {
                        if(
$data['disable']==1)
                        {
                            echo 
"You have been disabled<br>\n";
                        } 
                        else if(
$data['disable']==0)
                        {
                            echo 
"Logged in successfully<br>\n";
                            if(
$data['rank']==0)
                            {
                                echo 
"Hello Your rank is 0<br>\n";
                                include(
"membersnav.inc");
                            }
                            if(
$data['rank']==1)
                            {
                                echo 
"Hello Your rank is 1<br>\n";
                                
//include("membersnav.inc");
                            
}
                            if(
$data['rank']==2)
                            {
                                echo 
"Hello,Your Rank is Ensign<br>\n";
                                
//include("membersnav.inc");
                            
}
                            if(
$data['rank']==3)
                            {
                                echo 
"Hello,Your Rank is 1st General<br>\n";
                                
//include("membersnav.inc");
                            
}
                            if(
$data['rank']==4)
                            {
                                echo 
"Hello,Your Rank 1 star gen<br>\n";
                                
//include("membersnav.inc");
                            
}
                        }
                    }
                        else
                        {
                            
$msg_pass="Wrong Password,Please Try again<br>\n";
                        }
                    }
                    else
                    {
                        
$msg_user="Wrong Username,Please Try again<br>\n";
                    }
                }
            }
How do i go about doing this?