0

i am building a multi step login page like that of gmail,

i want the email address the the user typed in to be stored in a global variable so i can echo it in the next step of the form i have been trying but can't figure it out, have seen many error, when i change the code i get a different one the new one i have now is (Notice: Undefined index: email in C:\xampp\htdocs\xxxxx\index.php on line 3)

this is the form

<form action="" method="post" class="form-login">

    <div class="step-login step-one">
      <input type="text" class="email"/>

      <input type="button" class="btn next-step" value="next">
    </div>

  </form>

this is the php code that i am trying to use and store the input, i think this is where the problem is

<?php

$emails = $_POST['email'];

if(isset($_POST['next'])){
    $GLOBALS['email'] = $_GET['email'];
}

?>

this is the code where i am trying to echo the varible

<div class="data-user-find">
    <p class="user-email"><?php echo $GLOBALS['email']; ?></p>
  </div>

Please guys help me

Community
  • 1
  • 1
Britchi2
  • 37
  • 1
  • 7

1 Answers1

0

The "value" of your button is "next", but your button isn't called "next", it should be <button name="next" value="next" type="submit">

Then your error would go away. Also, you define an $email variable outside of your if-clause, please put it inside your if clause, so your code would be this:

<?php if(isset($_POST["next"]) { 
$email = $_POST["email"]; (DONT FORGET TO GIVE YOUR MAIL INPUT THE 'name="mail"' TAG)
$GLOBALS["email"] = $email;
} ?>
Tristan T.
  • 92
  • 1
  • 11