title: PHP header location function not working in form
body: <p>I'm trying to make a registration form for my website. I'm using the code below. All the error handlers work fine since it's adding the users into my database. I've trid to add ob_start. I removed all white spaces using a plugin for sublime text. I tried to use javascript instead of php (top.window). I also tried to use full url instead of just directories. But when I click submit it doesnt redirect me to the address I put after Location. When I click the button it takes me to this php file but doesnt redirect me back to the registration page which is a seperate file(I know there are a lot of similar questions that have been asked but they dont seem to work for my situation).
  Does anyone know how to fix that?
  
  
  <pre><code>if (isset($_POST['submit'])){
  
  include_once 'db.php';
  
  $uid = mysqli_real_escape_string($conn, $_POST['uid']);
  $pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
  $email = mysqli_real_escape_string($conn, $_POST['email']);
  
  //error handlers
  //Check for empty fields
  if (empty($uid) || empty($pwd) || empty($email)) {
  
      header("Location : /login/register.php?signup=empty");
      exit();
  
  } else{
  
      //Check if input characters are valid
      if (!preg_match("/^[a-zA-Z]*$/", $uid)) {
  
          header('Location: /login/register.php?signup=invalid');
          exit();
  
      } else {
  
          //Check if email is valid
          if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
              header('Location : /login/register.php?signup=email');
              exit();
          } else {
              $sql = "SELECT * FROM users WHERE user_uid='$uid'";
              $result = mysqli_query($conn, $sql);
              $resultCheck = mysqli_num_rows($result);
  
              if ($resultCheck &gt; 0) {
                  header('Location : /login/register.php?signup=usertaken');
              exit();
              } else {
                  //Hashing the password
                  $hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
                  //Insert the user into the databse
                  $sql = "INSERT INTO users (user_uid, user_pwd, user_email) VALUES ('$uid', '$hashedPwd', '$email');";
                  mysqli_query($conn, $sql);
                  header('Location : /login/register.php?signup=success');
                  exit();
              }
          }
  
  
  
      }
  
  }
  
  } else {
      header('Location : /login/register.php');
      exit();
  }
  </code></pre>
  
  <p><strong>Solved - Removing space after "location" answer by Nigel Ren</strong></p>