title: PHP Form to Database - Not working
body: <p>Once again I have a form that I want to submit to my database, but it is not working and I really have no idea why. I tested everything, but I can't see any error in my code.</p>
  
  <p>Here is the code of my form:</p>
  
  <pre><code>&lt;!-- Begin # Registration Form --&gt;
  &lt;form method="post" action="register_teacher.php" id="registration-teacher-form" class="form-horizontal"&gt;
  &lt;div class="col-sm-12"&gt;
      &lt;p&gt;Willkommen zu unserer &lt;strong&gt;Online - Essensreservierung&lt;/strong&gt; für Lehrer. Bitte geben Sie im nachfolgenden Schritt Ihre Daten bekannt. Die Wahl des Menüs, sowie die Essenstage, können Sie im nächsten Schritt angeben.&lt;/p&gt;&lt;br&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputEmail3" class="col-sm-2 control-label"&gt;Schule:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;select class="form-control" name="schul" id="schul"&gt;
          &lt;option value="no_selected" checked&gt;Bitte auswählen&lt;/option&gt;
          &lt;option value="AHS Waldschule 1"&gt;AHS Waldschule 1&lt;/option&gt;
          &lt;option value="AHS Waldschule 2"&gt;AHS Waldschule 2&lt;/option&gt;
          &lt;option value="AHS Waldschule 3"&gt;AHS Waldschule 3&lt;/option&gt;
      &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;hr&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputEmail" class="col-sm-2 control-label"&gt;Email:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="email" class="form-control" name="emai" id="inputEmail" placeholder="Ihre E-Mail Adresse"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputPassword" class="col-sm-2 control-label"&gt;Passwort:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="password" class="form-control" name="passwor" id="inputPassword" placeholder="Ihr Passwort"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;hr&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputEmail3" class="col-sm-2 control-label"&gt;Anrede:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;select class="form-control" name="anred"&gt;
              &lt;option value="Herr"&gt;Herr&lt;/option&gt;
              &lt;option value="Herr"&gt;Frau&lt;/option&gt;
          &lt;/select&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputVorname" class="col-sm-2 control-label"&gt;Vorname:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="text" class="form-control" name="vornam" id="inputVorname" placeholder="Ihr Vorname"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputNachname" class="col-sm-2 control-label"&gt;Nachname:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="text" class="form-control" name="nachnam" id="inputNachname" placeholder="Ihr Nachname"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputStrasse" class="col-sm-2 control-label"&gt;Strasse:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="text" class="form-control" name="strass" id="inputStrasse" placeholder="Ihre Adresse"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputPLZ" class="col-sm-2 control-label"&gt;PLZ:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="text" class="form-control" name="pl" id="inputPLZ" placeholder="Ihre Postleitzahl"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputOrt" class="col-sm-2 control-label"&gt;Ort:&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
          &lt;input type="text" class="form-control" name="or" id="inputOrt" placeholder="Ihr Wohnort"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputTelefon" class="col-sm-2 control-label"&gt;Telefon:&lt;/label&gt;
      &lt;div class="col-sm-10"&gt;
          &lt;input type="tel" class="form-control" name="telefo" id="inputTelefon" placeholder="Ihre Telefonnummer"&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;div class="col-sm-offset-2 col-sm-10"&gt;
          &lt;p&gt;Nachdem Sie die Registrierung abgesendet haben, erhalten Sie eine E-Mail mit einem Bestätigungslink. Sobald Sie Ihre E-Mail Adresse bestätigt haben, folgen Sie dem Link in der E-Mail um die Menüanmeldung durchführen zu können.
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;div class="col-sm-offset-2 col-sm-10"&gt;
              &lt;button type="submit" name="submit1" value="submit" class="btn btn-custom pull-right"&gt;Send&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;!-- End # Registration Form --&gt;
  </code></pre>
  
  <p>Here is the code of my register_teacher.php:</p>
  
  <pre><code>    &lt;?php
      // Create connection credentials
      $db_host = 'localhost';
      $db_name = 'DBNAME';
      $db_user = 'DBUSER';
      $db_pass = 'DBPASS';
  
  // Create mysqli object
  $connection = new mysqli ($db_host, $db_user, $db_pass, $db_name);
  
  // Error Handler
  if ($connection-&gt;connect_error) {
      printf ("Connection failed: %s\n", $connection-&gt;connect_error);
      exit();
  }   
  ?&gt;
  
  &lt;?php
  
  
  // Check if form is submitted
  if (isset ($_POST['submit1'])) {
      $schul = mysqli_real_escape_string ($connection, $_POST['schul']);
      $emai = mysqli_real_escape_string ($connection, $_POST['emai']);
      $passwor = mysqli_real_escape_string ($connection, $_POST['passwor']);
      $anred = mysqli_real_escape_string ($connection, $_POST['anred']);
      $vornam = mysqli_real_escape_string ($connection, $_POST['vornam']);
      $nachnam = mysqli_real_escape_string ($connection, $_POST['nachnam']);
      $strass = mysqli_real_escape_string ($connection, $_POST['strass']);
      $pl = mysqli_real_escape_string ($connection, $_POST['pl']);
      $or = mysqli_real_escape_string ($connection, $_POST['or']);
      $telefo = mysqli_real_escape_string ($connection, $_POST['telefo']);
  
  
  
  
      // Validate Input
  
  $sql="INSERT INTO `teacher` (`schule`, `email`, `password`, `anrede`, `firstname`, `lastname`, `street`, `plz`, `city`, `phonenumber`)
  VALUES ('$schul', '$emai', '$passwor' '$anred', '$vornam', '$nachnam', '$strass', '$pl', '$or', '$telefo')";
  
  
  
  $query1 = mysqli_query($connection, $sql );
  if(!mysqli_query($connection, $query1) ) {
      exit( header("Location: /teachercp/index.php") );
  }
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>MySQL connection is working. I also do not get any error message. Every time when I click on "Register", I am forwarded to a blank page on register_teacher.php! The redirection to teachercp/index.php is not working and no data is inside my database.</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks,
  Chris</p>