I am trying to pass a value from one form to another using sessions.

Form1:
Code:
<?php
  // Address error-handling.
  error_reporting(E_ALL & ~E_NOTICE);

  // Include Configuration Settings.
  require_once ('includes/config.inc.php');

  // Start output buffering.
  ob_start();

  // Initialize a session.
  session_start();
  echo "session_id() = " . session_id() . "<br />";

  // FUNCTION: Handle POST values.
  function input_post($name, $default = NULL) {
    return isset($_POST[$name]) ? $_POST[$name] : $default;
  }

  // Define variables.
  $email = input_post('email');
  $new_cust = input_post('new_cust');
  $password = input_post('password');
  $submitted = input_post('submitted');

  // Initialize array.
  $errors= array();

  // Handle form.
  if (isset($submitted)) {
    
    // Path to DB Connection Script.
    require_once (MYSQL);
    
    // Trim email.
	$email = trim($email);
    
   	// Validate E-mail address.
	if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $email)) {
		$e = mysqli_real_escape_string ($dbc, $email);
	} else {
        $errors['email']='Please enter a valid E-mail address.';
	}

    // Check for errors.
    if(empty($errors)) {
        // Data Valid.
        // Build query.
        $q = "SELECT user_id FROM users WHERE email='$e'";

        // Run query.
		$r = mysqli_query ($dbc, $q)
                    or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));

        // Check for duplicate E-mail.
		if (mysqli_num_rows($r) == 0) {
          // Available.
          // Assign validated Email to session variable.
          $_SESSION['email'] = $e;
          echo '$_SESSION[\'email\'] = ' . $_SESSION['email'];
          // Continue Registration.
          header('Location: 104_CreateUser.php');
        } else {
          // Not Available.
          $errors['email']='This e-mail has already been registered!!';
        }
    }
  }
  ob_end_flush();
?>

Form 2:

Code:
<?php
  //This page processes...

  // Address error-handling.
  error_reporting(E_ALL & ~E_NOTICE);

  // Include Configuration Settings.
  require_once ('includes/config.inc.php');

  // Start output buffering.
  ob_start();

  // Initialize a session.
  session_start();
  echo "session_id() = " . session_id() . "<br />";

  // FUNCTION: Handle POST values.
  function input_post($name, $default = NULL) {
    return isset($_POST[$name]) ? trim($_POST[$name]) : $default;
  }

  echo "POST = " . input_post('$_POST['email1']');

  // Define variables.
  $email1 = input_post('email1');
  echo "email1 = " . $email1;

Question:

Why can't I reference the value in my Email1 input box?

The session variable is copied into the Input Box, however, when I reference $_POST['email1'] I'm getting some Undefined Index error.

And no value is printing for echo $email1?!

What is happening?


Amy