title: PHP registration/login error
body: <p>I'am trying to create register/login system. However, I've faced some problems. I can't understand where's the mistake in my code.
  Here's my server.php &amp; register.php. Browser shows that mistake is in line 65. "Parse error: syntax error, unexpected ';'". In my opinion ; must be there.</p>
  
  <pre><code>    &lt;?php
  session_start();
      $username = "";
      $email = "";
      $errors = array();
  // Connect to the database
  $db = mysqli_connect('localhost', 'root', '', 'lead2pro');
  // If the register button is clicked
      if(isset($_POST['register'])) {
          $username = mysqli_real_escape_string($db, $_POST['username']);
          $email = mysqli_real_escape_string($db, $_POST['email']);
          $password_1 = mysqli_real_escape_string($db ,$_POST['password_1']);
          $password_2 = mysqli_real_escape_string($db, $_POST['password_2']);
          // Ensure that form fields are filled properly
      if(empty($username)) {
              array_push($errors, "Username is required!");
          }
      if(empty($email)) {
              array_push($errors, "Email is required!");
          }
      if(empty($password_1)) {
              array_push($errors, "Password is required!");
          }
      if($password_1 != $password_2) {
          array_push($errors, "The two passwords do not match");
          }
          // If there are no errors, save user to database
          if(count($errors) == 0) {
              $password = md5($password_1); // Hashin the password before storing in database
              $sql = "INSERT INTO users (username, email, password) VALUES('$username', '$email', '$password')";
              mysqli_query($db, $sql);
              $_SESSION['username'] = $username;
              $_SESSION['success'] = "You are now logged in";
              header('location: ../system.php'); // Redirect to game location
          }
      }
  // log user in from login page 
      if(isset($_POST['login'])) {
          $username = mysqli_real_escape_string($db, $_POST['username']);
          $password = mysqli_real_escape_string($db, $_POST['password']);
          // Ensure that form fields are filled properly
      if(empty($username)) {
              array_push($errors, "Username is required!");
          }
      if(empty(password)) {
              array_push($errors, "Password is required!");
          }
          if(count($errors) == 0){
              $password = md5($password); // Encrypt password before comparing this one with the one in database
              $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
              $result = mysqli_query($db, $query);
              $if (mysqli_num_rows($result) == 1) {
              $_SESSION['username'] = $username;
              $_SESSION['success'] = "You are now logged in";
              header('location: ../system.php'); // Redirect to main page location
              } else {
                  array_push($errors, "Wrong username/password combination");
                      header('location: ../php/login.php');
              }
          }
      }
  //logout
      if(isset($_GET['logout'])) {
          session_destroy();
          unset($_SESSION['username']);
          header('location: ../php/login.php');
      }
  ?&gt;
  </code></pre>
  
  <p>Here's my register.php</p>
  
  <pre><code>&lt;?php include('../includes/server.php');?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Manager | Register&lt;/title&gt;
      &lt;link rel="stylesheet" href="../css/reg.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="header"&gt;
          &lt;h2&gt;Register&lt;/h2&gt;
      &lt;/div&gt;
  &lt;!--    Display validation errors here!     --&gt;
     &lt;?php include('../includes/errors.php');   ?&gt;
      &lt;form action="register.php" method="post"&gt;
          &lt;div class="input-group"&gt;
              &lt;label&gt;Username&lt;/label&gt;
              &lt;input type="text" name="username" value="&lt;?php echo $username; ?&gt;"&gt;
          &lt;/div&gt;
          &lt;div class="input-group"&gt;
              &lt;label&gt;Email&lt;/label&gt;
              &lt;input type="text" name="email" value="&lt;?php echo $email; ?&gt;"&gt;
          &lt;/div&gt;
          &lt;div class="input-group"&gt;
              &lt;label&gt;Password&lt;/label&gt;
              &lt;input type="password" name="password_1"&gt;
          &lt;/div&gt;
          &lt;div class="input-group"&gt;
              &lt;label&gt;Confirm Password&lt;/label&gt;
              &lt;input type="password" name="password_2"&gt;
          &lt;/div&gt;
          &lt;div class="input-group"&gt;
          &lt;button type="submit" name="register" class="btn"&gt;Register&lt;/button&gt;
          &lt;/div&gt;
          &lt;p&gt;
              Already a member? &lt;a href="login.php"&gt;Sign in&lt;/a&gt;
          &lt;/p&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>