title: PHP connection to MySQL database not working
body: <p>I am trying to create a login to database, using PHPMyAdmin with MAMP. I have made a simple login form in index.html and placed my php code in connect.php to open home.php once the correct username and password are put in. But when I input username and password (or even when I input random text) I am taken to localhost:8888/connect.php with no error message, just a blank page. Any ideas?</p>
  
  <p>This is the index.html code</p>
  
  <pre><code>&lt;head&gt;
    &lt;body&gt;
      &lt;font&gt;
        &lt;center&gt;&lt;h1&gt;Login&lt;/h1&gt;&lt;/center&gt;
      &lt;/font&gt;
      &lt;form action="connect.php" method="POST"&gt;
        Username:&lt;input type="text" name="username"&gt;
        Password:&lt;input type="password" name="pass"&gt;&lt;br&gt;
        &lt;input type="submit" value="login" name="submit"&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>And this is in connect.php</p>
  
  <pre><code>&lt;?php
  
  require ('msql_connect.php');
  if (isset($_POST['submit'])){
      $username=mysql_escape_string($_POST['username']);
      $password=mysql_escape_string($_POST['pass']);
  
  }
  $inputuser = $_POST['user'];
  $inputpass = $_POST['pass'];
  
  $user = "root";
  
  $database = "test";
  
  @mysql_select_db($database) or ("Database not found");
  
  $query = "SELECT * FROM 'login' WHERE 'user' = '$username' AND 'password' = '$password'";
  
  $result = mysql_query($query);
  $row = mysql_fetch_array($result);
  
      if(!$result){
          echo "Sorry, bad login";
          die("Username or password is invalid");
          //Might be better to redirect back to the login page with a freindly message
      } else {
  
      $valid_user = mysql_fetch_array($result); 
      mysql_close();
      header('Location: home.php');
    }
  ?&gt;
  </code></pre>
  
  <p>UPDATE: 
  There is no mysql_connect.php, I've changed the all mysql_ to mysqli_, and commented out the require() and it brings me to an error message of wrong username and password, but they should be working.</p>
  
  <p>Now looks like this </p>
  
  <pre><code>&lt;?php
  
  // require ('connect.php');
  if (isset($_POST['submit'])){
      $username=mysqli_escape_string($_POST['username']);
      $password=mysqli_escape_string($_POST['pass']);
  
  }
  $inputuser = $_POST['user'];
  $inputpass = $_POST['pass'];
  
  $user = "root";
  $password = "";
  $database = "fuf_db";
  $connect = mysqli_connect("localhost",$user,$password);
  @mysqli_select_db($database) or ("Database not found");
  
  $query = "SELECT * FROM 'SuperAdminUsers' WHERE 'user' = '$username' AND 'password' = '$password'";
  
  $result = mysqli_query($query);
  
      if(!$result){
          echo "Sorry, bad login";
          die("Username or password is invalid");
      } else {
          // $row = mysqli_fetch_array($result);
  
      $valid_user = mysqli_fetch_array($result); 
      mysqli_close();
      header('Location: home.php');
    }
  ?&gt;
  </code></pre>
  
  <p>These are the errors I'm getting :-</p>
  
  <p>Warning: mysqli_escape_string() expects exactly 2 parameters, 1 given in .../connect.php on line 5</p>
  
  <p>Warning: mysqli_escape_string() expects exactly 2 parameters, 1 given in .../connect.php on line 6</p>
  
  <p>Notice: Undefined index: user in .../connect.php on line 9</p>
  
  <p>Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in .../connect.php on line 15</p>
  
  <p>Warning: mysqli_query() expects at least 2 parameters, 1 given in .../connect.php on line 20
  Sorry, bad loginUsername or password is invalid</p>