title: MSSQL PHP Authentication System is not Logging in
body: <p>I have a MSSQL table named users with the username <code>rob_dewar01</code> and the password <code>0b1a1953c219343f3313f0feae9abbe8</code>. The password was put into the table as MD5 using PHP code and translates to <code>KingDozer</code> without MD5. There is a page called login.php that has a form with two inputs where the user may input the username and password. The login.php will send to the check.php page when the user hits submit. The check.php should then check if the username and password is correct, then send the user to the management page. If the username and password is incorrect, the check.php page will send the user back to the login.php page. My problem is when I try to correctly input the username <code>rob_dewar01</code> and the password <code>KingDozer</code> into the login.php page and hit submit, it sends me right back to the login.php page. I am not sure if this is happening because it is being used with MSSQL or PHP.</p>
  
  <p>Here is the login.php page code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
      &lt;title&gt;Login to === Back-end&lt;/title&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;form method="POST" action="check.php"&gt;
        Username:&lt;br /&gt;
        &lt;input type="text" name="username" /&gt;
        &lt;br /&gt;&lt;br /&gt;
        Password:&lt;br /&gt;
        &lt;input type="password" name="password" /&gt;
        &lt;br /&gt;&lt;br /&gt;
        &lt;input type="submit" id="subbut" value="Submit" /&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is all my PHP code for check.php:</p>
  
  <pre><code>&lt;?php
    session_start();
  
    if($_SERVER['REQUEST_METHOD'] == "POST") {
  $conn=mssql_connect('gsom','Gser','Ros1!');
  mssql_select_db('GBsr',$conn);
  if(! $conn )
  {
    die('Could not connect: ' . mssql_get_last_message());
  }
  
      $username = ($_POST['username']);
      $password = ($_POST['password']);
  
      $result = mssql_query("SELECT * FROM users WHERE username='$username' AND
        password=md5('$password')");
    if(mssql_num_rows($result) &gt; 0) {
        $_SESSION['is_logged_in'] = 1;
      }
    }
  
    if(!isset($_SESSION['is_logged_in'])) {
      header("location:login.php");
    } else {
      header("location:careers/managecareers.php");
    }
  ?&gt;
  </code></pre>
  
  <p>Here is the PHP page's code I used to insert a username and password into the MSSQL table users:</p>
  
  <pre><code>&lt;?php
  $conn=mssql_connect('gbscom','GBser','Robs!');
  mssql_select_db('Gser',$conn);
  if(! $conn )
  {
    die('Could not connect: ' . mssql_get_last_message());
  }
  
  mssql_query($conn,"INSERT INTO Users (username, password)
  VALUES ('rob_dewar01', md5('KingDozer'))");
  
  
  if (!mssql_query) {
      // The query has failed, print a nice error message
      // using mssql_get_last_message()
      die('MSSQL error: ' . mssql_get_last_message());
  }
  
  mssql_close($conn);
  ?&gt;
  </code></pre>
  
  <p>Any help is appreciated. Thank you for any help.</p>