If $var == X then redirect not working
<p>Im trying to redirect my users to a page based on the value of a variable posted via a form. I have the following that doesnt redirect however...</p>

<pre><code>if ($error) {
  echo "All fields are required.";
} else {
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $email = $_POST['email'];
    $password = md5($_POST['password']);
    $accounttype = $_POST['accounttype'];

    $query = "INSERT INTO users(firstname,lastname,email,password,accounttype) VALUES (:firstname,:lastname,:email,:password,:accounttype)";
      $stmt = $dbh-&gt;prepare($query);
      $stmt-&gt;bindParam(':firstname', $firstname);
      $stmt-&gt;bindParam(':lastname', $lastname);
      $stmt-&gt;bindParam(':email', $email);
      $stmt-&gt;bindParam(':password', $password);
      $stmt-&gt;bindParam(':accounttype', $accounttype);
      $stmt-&gt;execute();

    if(!query){
        echo 'Whoops, something went wrong!';
    } else {
        echo $accounttype;
    };
};
</code></pre>
