title: change user login status from admin panel in PHP
body: <p>I am working on a system which user can register and login and see there own profile &amp; have a Main Admin who can see and modify the user login STATUS. If admin change the user status then user can't login to his account. (block User). Predefined user status is "Y" and if admin want to restrict that user to login admin can change the status to "N" so user can't login.</p>
  
  <p>i am learning php and i don't get the right technique  to do that.</p>
  
  <p><strong>Below is the code where I show the user table and wan to change the status.</strong></p>
  
  <pre><code>&lt;table border="1" class="pricing-table-wrapper col-sm-4"&gt;
      &lt;tr&gt;
          &lt;th&gt;Id&lt;/th&gt;
          &lt;th&gt;Username&lt;/th&gt;
          &lt;th&gt;Email&lt;/th&gt;
          &lt;th&gt;password&lt;/th&gt;
          &lt;th&gt;first_name&lt;/th&gt;
          &lt;th&gt;last_name&lt;/th&gt;
          &lt;th&gt;city&lt;/th&gt;
          &lt;th&gt;signup_date&lt;/th&gt;
          &lt;th&gt;ac_number&lt;/th&gt;
  
          &lt;th&gt;bank_name&lt;/th&gt;
          &lt;th&gt;Status&lt;/th&gt;
          &lt;th&gt;Action&lt;/th&gt;
  
  
      &lt;/tr&gt;
      &lt;?php
      //We get the IDs, usernames and emails of users
      $req = mysqli_query($conn, 'select id, username, email, password, first_name, last_name, city, signup_date, ac_number, bank_name, status from users');
      while($dnn = mysqli_fetch_array($req))
      {
      ?&gt;
      &lt;tr&gt;
          &lt;td class="left"&gt;&lt;?php echo $dnn['id']; ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['password'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['first_name'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['last_name'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['city'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['signup_date'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['ac_number'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['bank_name'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
  
  
          &lt;td class="left"&gt;&lt;?php echo htmlentities($dnn['status'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
          &lt;td class="left"&gt;CHANGE USER STATUS&lt;/td&gt;
  
  
  
  
             &lt;?php
           }
        ?&gt;
  
      &lt;/tr&gt;
  
      &lt;/table&gt;
  </code></pre>
  
  <p>THE CODE WHICH I TRIED </p>
  
  <pre><code> &lt;td&gt;
  
          &lt;a href='changestatus.php?id=&lt;?=$dnn['id']?&gt;'&gt;
  
              &lt;img src="a6block.jpg" width="50px" &gt;
  
  
          &lt;/a&gt;
  
  
          &lt;?php 
  
          include('config.php');
  
          if(isset($_GET['id']))
          {
  
          // lookup the current status of user 'id'
  
          // Update DB with the new status    
  
          $sql_query="SELECT * FROM users WHERE id=".$_GET['id'];
              $result_set=mysqli_query($conn, $sql_query);
              $fetched_row=mysqli_fetch_array($result_set);
  
  
               $sql_query = "UPDATE users SET status='N' WHERE id=".$_GET['id'];
              mysqli_query($conn, $sql_query);
  
  
  
          }
          header("Location: users.php");
  
          exit;
          // redirect back to the previous page
  
  
          ?&gt;
  </code></pre>
  
  <p>?></p>
  
  <p>THIS IS MAY BE A WRONG TECHNIQUE SO WHAT CAN I DO?</p>