title: Passing results from a MySQL query through to a PHP session login
body: <p>I'm trying to fix a login system from a friend's older project, and I can't seem to get it to accept a legitimate login, instead of going and passing the user's name and ID from the DB through, it just throws the error, even when it can get the correct username and ID from the DB. Any idea if it's this part of the code causing the error and what the solution is?</p>
  
  <p><strong>MySQL Query and PHP Session</strong></p>
  
  <pre><code>&lt;?php
  $row = mysqli_fetch_assoc(mysqli_query($con,'SELECT id,usr FROM tz_members WHERE usr="{.$_POST[username]}" AND pass="{.$_POST[password]}"'));
  if($row['usr'])
  {
      $_SESSION['usr'] = $row['usr'];
      $_SESSION['id'] = $row['id'];
      $_SESSION['rememberMe'] = $_POST['rememberMe'];
  }
  else {
      //(display error message)
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Login Form</strong>      </p>
  
  <pre><code>&lt;form&gt;
      &lt;label class="grey" for="username"&gt;Username:&lt;/label&gt;
      &lt;input class="field" type="text" name="username" id="username" value="" size="23" /&gt;
      &lt;label class="grey" for="password"&gt;Password:&lt;/label&gt;
      &lt;input class="field" type="password" name="password" id="password" size="23" /&gt;
      &lt;label&gt;&lt;input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /&gt; &amp;nbsp;Remember me&lt;/label&gt;
      &lt;div class="clear"&gt;
      &lt;/div&gt;
      &lt;input type="submit" name="submit" value="Login" class="bt_login" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Full code</strong></p>
  
  <p><a href="http://pastebin.com/kj6i9Y8h" rel="nofollow noreferrer">http://pastebin.com/kj6i9Y8h</a></p>