title: PHP redirect on button click
body: <p>I'm new to PHP programming and have a simple program where I have an index page which accepts username and password. If user doesn't exist or wrong credentials are provided then I want to show index page again with error message. Here is what I have so far on my index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
  
      &lt;meta 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;meta name="description" content=""&gt;
      &lt;meta name="author" content="Bella" &gt;
  
      &lt;title&gt;Company Name - Log In&lt;/title&gt;
  
      &lt;!-- Bootstrap Core CSS --&gt;
      &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
  
      &lt;!-- Custom CSS --&gt;
      &lt;link href="css/custom.css" rel="stylesheet"&gt;
  
      &lt;!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --&gt;
      &lt;!-- WARNING: Respond.js doesn't work if you view the page via file:// --&gt;
      &lt;!--[if lt IE 9]&gt;
          &lt;script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"&gt;&lt;/script&gt;
          &lt;script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"&gt;&lt;/script&gt;
      &lt;![endif]--&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;div id="fullscreen_bg" class="fullscreen_bg"/&gt;
  
  &lt;div class="container"&gt;
  
      &lt;form class="form-signin" action="loginAction.php" method="post"&gt;
          &lt;h1 class="form-signin-heading text-muted"&gt;Log In&lt;/h1&gt;
          &lt;input type="text" name="email" class="form-control" placeholder="Email address" required="" autofocus=""&gt;
          &lt;input type="password" name="password" class="form-control" placeholder="Password" required=""&gt;
          &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;
              Log In
          &lt;/button&gt;
      &lt;a href="register.html" class="btn btn-md btn-warning btn-block"&gt;Register&lt;/a&gt;       
      &lt;/form&gt;
  
  &lt;/div&gt;
      &lt;!-- /.container --&gt;
  
      &lt;!-- jQuery --&gt;
      &lt;script src="js/jquery.js"&gt;&lt;/script&gt;
  
      &lt;!-- Bootstrap Core JavaScript --&gt;
      &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  
      &lt;!-- Script to Activate the Carousel --&gt;
      &lt;script&gt;
      $('.carousel').carousel({
          interval: 5000 //changes the speed
      })
      &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>My LoginAction.php is:</p>
  
  <pre><code>&lt;?php
  
  ini_set('display_errors',1);
  error_reporting(E_ALL);
  
  //Set the Post results to variables
  $email = $_POST("email");
  $password = md5($_POST("password"));
  
  //Get the database username, passwords, etc.
  include('config.php');
  
  // Create connection with the server
  $conn = mysqli_connect($servername, $username, $password, $dbname);
  
  // Check connection
  if (!$conn) {
      die("Connection failed: " . mysqli_connect_error());
  }
  
  //Check for user
  $sql = "SELECT * FROM users WHERE  email=" . $email . " AND password=" . $password . "";
  $result = mysqli_query($conn, $sql);
  
  if (mysqli_num_rows($result) &gt; 0) {
      // output data of each row
      while($row = mysqli_fetch_assoc($result)) {
            mysqli_close($conn);
            session_start();
            $_SESSION['email'] = $row['email'];
            $_SESSION['id'] = $row['id'];
            $_SESSION['admin'] = true; //user is authenticated and the user is admin
            header"portal.php"; //redirect to another page
  
      }
  } 
  else {
      mysqli_close($conn);
      echo "&lt;div class='alert alert-warning'&gt;No User Found&lt;/div&gt;";
      //header("Location: http://example.com/myOtherPage.php");
      //header"portal.php"; //redirect to another page
     include"index.html";
  }
  
  ?&gt;
  </code></pre>
  
  <p>It currently shows me blank LoginAction.php</p>