title: Session Data overwriting in a two page form PHP
body: <p>To register a user, I am using a form that consists of two pages. the first form(addUser.php) sends the data over post to the second form(plz.php). In the second form I save the post values from the previous page in session variables, for example </p>
  
  <pre><code>     $_SESSION['phone1'] = $_POST['telnr'];
  </code></pre>
  
  <p>I have checked and the data is sent correctly to the second form. 
  The second form has only one dropdown and after an option is selected, it is supposed to save all data in the database. 
  The problem is that when I send the second form, all session variables are overwritten and I get a error message "email cannot be null". I am assuming the other variables are overwritten too.
  I have tried so far saving the session data in an array and then extracting it but no luck.
  The second form looks like this. And yes, sessions are started at the top of each file.</p>
  
  <pre><code>    $_SESSION['email1'] = $_POST['email'];
      $_SESSION['passwort1'] = $_POST['passwort'];
      $_SESSION['vname1'] = $_POST['vname'];
      $_SESSION['fname1'] = $_POST['fname'];
      $_SESSION['phone1'] = $_POST['telnr'];
      $_SESSION['firma1'] = $_POST['firmen_name'];
      $_SESSION['ad11'] = $_POST['adresse1'];
      $_SESSION['ad21'] = $_POST['adresse2'];
      $_SESSION['kr1'] = $_POST['kreis'];
      //$_SESSION["plz1"] = $_POST['plz'];
      if(isset($_POST['submit'])){
  
  
      // Passwort wird gehasht und in der Datenbank gespeichert, bcrypt 
      algorithm, cost = 10, salt wurde automatisch generiert und ist unique
      $hash = password_hash($_SESSION['passwort1'], PASSWORD_DEFAULT);
  
                  $insert = "INSERT INTO users 
      (email,passwort,vname,fname,firmen_name,telnr, userlevel, active, 
      adresse1, adresse2, kreis, plz) VALUES 
      (:email,:hash,:vname,:fname,:firma,:phone,1,0, :adresse1, :adresse2, 
      :kreis, :plz)";
                  $prepStmt = $pdo-&gt;prepare($insert);
                  $prepStmt -&gt;bindParam("email", $_SESSION['email1']);    
                  $prepStmt -&gt;bindParam("hash", $hash);
                  $prepStmt -&gt;bindParam("vname", $_SESSION['vname1']);
                  $prepStmt -&gt;bindParam("fname", $_SESSION['fname1']);
                  $prepStmt -&gt;bindParam("firma", $_SESSION['firma1']);
                  $prepStmt -&gt;bindParam("phone", $_SESSION['phone1']);
                  $prepStmt -&gt;bindParam("adresse1", $_SESSION['ad11']);
                  $prepStmt -&gt;bindParam("adresse2", $_SESSION['ad21']);
                  $prepStmt -&gt;bindParam("kreis", $_SESSION['kreis1']);
                  $prepStmt -&gt;bindParam("plz", $_POST["plz1"]);
                  $prepStmt -&gt;execute();
                  header("Location: users.php");
                  exit();
    }else{
    ?&gt;
    &lt;div class="container"&gt;
              &lt;div class="col-md-offset-3 col-md-7"&gt;
              &lt;form action="plz.php" method="post" class="text-center col-md-
    offset-0.5 "&gt;
              &lt;!-- more form --&gt;
  </code></pre>