title: PHP MySQL Login works on Local Server but not on Public Server
body: <p>I played around a bit with a PHP and MySQL Login and realized its pretty easy to sql inject. So I changed a few things so instead of <code>$query</code> I used <code>$smtp</code> and so on.</p>
  
  <p>The page loads and works on my local server (xammp) but when I upload it to my public server I get a <strong>500 Internal Server Error</strong> (the page worked before the changes)</p>
  
  <p>I did not change anything to the HTML, its only the PHP part that makes the problem.</p>
  
  <p>And this is my code which works on the local server but <strong>not</strong> on the public server:</p>
  
  <pre><code>&lt;?php
  session_start();
   require('../db/DBconnect.php');
   $select_db = mysqli_select_db($connection, 'website');
  if (!$select_db){
      die("Database Selection Failed" . mysqli_error($connection));
  }
  
  if (isset($_POST['username']) and isset($_POST['password'])){
  
  $username = $_POST['username'];
  $password = $_POST['password'];
  //$query = "SELECT * FROM `users` WHERE userName='$username' and userPass='$password'"; OLD LOGIN
  $stmt = $connection-&gt;prepare('SELECT * FROM users WHERE userName= ? and userPass= ?');
  $stmt-&gt;bind_param('is', $username, $password);
  
  $stmt-&gt;execute();
  
  //$result = $stmt-&gt;get_result(); OLD LOGIN
  //while ($row = $result-&gt;fetch_assoc()) { OLD LOGIN
      // do something with $row OLD LOGIN
  //} OLD LOGIN
  $result = $stmt-&gt;get_result();
  //$result = mysqli_query($connection, $stmt) or die(mysqli_error($connection)); OLD LOGIN
  $count = mysqli_num_rows($result);
  if ($count == 1){
  $_SESSION['username'] = $username;
  }else{
  $fmsg = "Invalid Login Credentials.";
  }
  }
  if (isset($_SESSION['username'])){
  $username = $_SESSION['username'];
  header('Location: /beta/adminpanel.php');
  }else{
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;base href="/"&gt;
    &lt;html lang="en"&gt;&lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Admin - Freunde Gamen &amp;hearts;&lt;/title&gt;
      &lt;link href="../host-files/bootstrap.css" rel="stylesheet"&gt;
      &lt;link href="../host-files/admin.css" rel="stylesheet"&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;base href="/"&gt;
      &lt;link rel="icon" href="../favicon.ico" type="image/x-icon"/&gt;
  &lt;/head&gt;
    &lt;body&gt;
  &lt;div class="container"&gt;
      &lt;div class="login"&gt;
  
        &lt;form class="form-signin" method="POST"&gt;
        &lt;?php if(isset($fmsg)){ ?&gt;&lt;div class="alert alert-danger" role="alert"&gt; &lt;?php echo $fmsg; ?&gt; &lt;/div&gt;&lt;?php } ?&gt;
          &lt;h2 class="form-signin-heading"&gt;FG - Admin Login&lt;/h2&gt;
          &lt;div class="input-group"&gt;
      &lt;span class="input-group-addon" id="basic-addon1"&gt;@&lt;/span&gt;
      &lt;input type="text" name="username" class="form-control" placeholder="Username" required&gt;
    &lt;/div&gt;
          &lt;label for="inputPassword" class="sr-only"&gt;Password&lt;/label&gt;
          &lt;input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required&gt;
          &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;Login&lt;/button&gt;
        &lt;/form&gt;
  &lt;/div&gt;
      &lt;/div&gt;
      &lt;script src="../host-files/js/bootstrap.js"&gt;&lt;/script&gt;
      &lt;script src="../host-files/js/jquery.min.js"&gt;&lt;/script&gt;
  
  
  &lt;/body&gt;&lt;/html&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>Both Local and Public server use:<br>
  Apache/2.4.10<br>
  PHP Version 5.6.33-0+deb8u1 ( I know I should update to PHP 7)<br>
  Share the same MySQL DB and Server</p>