title: Force user to change password on first login
body: <p>I'm creating a login module. The admin and the users use the same page for login. Based on the credentials the page directs accordingly to admin and user pages. After the admin logs in, the admin adds the users and assigns them a password. With this password the users login. My project works till here. The problem is , I have to write a script to force the user to change the password when they login for the first time. </p>
  
  <p>For this, I have created a login table which consists of username,password,fname.</p>
  
  <p>I'm a beginner in php. Hence stuck.</p>
  
  <p>Please help me.</p>
  
  <p>Login.php</p>
  
  <pre><code> {
    $_SESSION['login'] = "OK";
    $_SESSION['username'] = $user;
    $_SESSION['password'] = $pass;
    header('Location: adminpage.php');
  
  }
  
  else
  
  {
    $_SESSION['login'] = "";
  
    header('Location: wrong.html');    
  }
  </code></pre>
  
  <p>adminpage.php</p>
  
  <pre><code> if($_SESSION['username'] == 'admin')
  {
    echo "&lt;p align=right&gt;&lt;a href='login.php'&gt;Log out&lt;/a&gt;&lt;/p&gt;";     
    echo "&lt;p&gt;&lt;a href='create_user.php'&gt;Create a new user&lt;/a&gt;&lt;/p&gt;";
    echo "&lt;p&gt;&lt;a href='reports.php'&gt;Reports&lt;/a&gt;&lt;/p&gt;";
  
  }
    elseif
    {
        header('Location: userpage.php');
    }
  </code></pre>