Q: PHP Session for input value with Submit form I have 2 Pages, where an user must enter his Email Address on the first Page and on the Second page his Password, but i want display also the entered Email address above the Password.
I have tried it with PHP Session
Email Page:
<form action="save.php" method="post">
<input id="email" name="email" type="email" value="" placeholder="E-Mail-Adresse">
<button class="button actionContinue" type="submit" id="btnLogin" name="btnLogin" value="Login" pa-marked="1">Einloggen</button></form>

save.php:
    <?php
   header("Location: /password");

    session_start(); 
    $name = $_POST['email'];

    if(!isset($name) OR empty($name)) {
       $name = "Gast";
    }

    $_SESSION['email'] = $name;

    echo "Hallo $name ";

    ?>

Password Page (Page 2):
<p> Geben Sie ihr Passwort ein:</p>



<?php
session_start(); 

if(!isset($_SESSION['email'])) {
   die("Login first");   
}

$name = $_SESSION['email'];

echo "Your email is: $name";
?>

Why the entered email address dont shows on the password Page? Whats wrong?

A: session_start() must be called before any display (raw text, HTML, ...), your password file should begin as:
<?php session_start(); ?>
<p> Geben Sie ihr Passwort ein:</p>
...

Also, you are calling header() at the begining of your save.php file. The lines after the function won't be executed, meaning that $_SESSION['email'] won't be defined.
Note that header() needs to be called before any output too !

Reading the session_start() documentation:

Note:
  To use cookie-based sessions, session_start() must be called before outputing anything to the browser.


A: Because you used $name for two places. You should change $name = $_POST['email']; to $email = $_POST['email']; 
Because below code is override your $name
if(!isset($name) OR empty($name)) {
       $name = "Gast"; //if the name is not empty Gast will store inside $name
    }

Use the below code.
save.php page
 <?php


    session_start(); 
    $email = $_POST['email'];

    if(!isset($name) OR empty($name)) {
       $name = "Gast";
    }

    if($email != NULL){
      $_SESSION['email'] = $email;
       echo "Hallo $name ";
      header("Location: /password");
    }

    ?>

Password page
<?php
session_start(); 

if(!isset($_SESSION['email'])) {
   die("Login first");   
}

echo "Your email is: $_SESSION['email']";
?>
 <p> Geben Sie ihr Passwort ein:</p>

