title: Php sessions login - nothing happens, why?
body: <p>I have a MySQL database with a user called admin (and password admin). I am using this to test my configuration. When I click login, nothing happens. Can anyone see if I've done something wrong?</p>
  
  <p>Here is my logon form:</p>
  
  <pre><code>    &lt;form action="loginProcess.php" method="POST"&gt;
      Username: &lt;input type='text' name='username'&gt;&lt;/br&gt;
  
      &lt;!-- input type password makes the password hidden as it is typed --&gt;
      &amp;nbsp;Password: &lt;input type='password' name='password'&gt;&lt;/br&gt;
  
  
      &lt;input type='submit' value='Login'/&gt;
  
      &lt;/form&gt;
      &lt;/br&gt;
      &lt;/br&gt;
      &lt;!-- Register New User --&gt;
      &lt;form action="register.php" method="POST"&gt; &lt;/br&gt;
      Not Registered?&lt;input type='submit' value='Click Here To Register'/&gt;
  
      &lt;/form&gt;
  </code></pre>
  
  <p>This form takes you to this loginProcess.php file:</p>
  
  <pre><code>&lt;?php
  ob_start();
  session_start();
  // Include database connection and select database UFPProducts
  include "./shopdb/connection.php";
  
  ?&gt;
  &lt;?php
      //
  // (2) Collect data from form and save in variables
  // real escape string to protect from SQLi attacks
  $username=mysql_real_escape_string(htmlentities($_POST['username']));
  $password=mysql_real_escape_string(htmlentities($_POST['password']));
  
  // (3) Create query of the form below to search the user table
  //   "SELECT * FROM Users WHERE UserName='$username' AND  Password='$password'"
  
  $query = "SELECT * FROM USERS where Username='$username' AND Password='$password'";
  $result = mysql_query($query) or die (mysql_error()); 
  
  // (3) Run query through connection
  
  // (4) Check result of query using code below
  
  // if rows found set authenticated user to the user name entered 
  if (mysql_num_rows($result) &gt; 0) { 
  $_SESSION["authenticatedUser"] = $username;
  // Relocate to the logged-in page
  header("Location: ./login/loggedOn.php");
  } 
  else
  // login failed redirect back to login page with error message
  {
  $_SESSION["message"] = "Could not connect as $username " ;
  header("Location: login.php");
  }
  ?&gt;
  </code></pre>
  
  <p>And here is my connection.php file just incase anyone wants to see:</p>
  
  <pre><code>&lt;?php 
  //***  "die()" will exit the script and show an error if something goes wrong with the "connect" or "select" functions. 
  //***  A "mysql_connect()" error usually means your connection specific details are wrong 
  //***  A "mysql_select_db()" error usually means the database does not exist.
  
  // Place db host name. Usually is "localhost" but sometimes a more direct string is needed
  $db_host = "localhost";
  // Place the username for the MySQL database here
  $db_username = "root"; 
  // Place the password for the MySQL database here
  $db_pass = "";
  // Place the name for the MySQL database here
  $db_name = "UFPProducts";
  
  $connect = mysql_connect("$db_host","$db_username","$db_pass") or die(mysql_error());
  mysql_select_db("$db_name") or die("there is no database with that name");
  
  // echo "&lt;center&gt;You are successfully connected to the Under5Pounds database.&lt;/center&gt;&lt;br&gt;";
  ?&gt;
  </code></pre>
  
  <p>I'm not getting any error messages right now, it just doesn't do anything once I type in the username + password and click login.</p>