PHP form help

Discussion in 'PHP' started by ziplock122949, Jun 14, 2008.

  1. #1
    I need some help with this form. I have a form on one page where someone can enter their email address to join a newsletter. Once they hit submit, it takes them to a 2nd page which asks if the address they entered was correct then submits it to a 3rd page which emails the email address and forwards them back to the site. Right now, everything is working except the 2nd page is not passing the email address entered to the 3rd page. Here is the code from the 2nd page

    <form method="post" action="join.php">
    <?php 
    $email_address = $_POST['email_address'];
    print "If $email_address is correct, please press the submit button below.<br><br>";
    ?>
    
    <input type="submit" name="submit" value="Submit" />
    </form>
    PHP:
     
    ziplock122949, Jun 14, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll have to throw a hidden input in your form too containing the email address. Right now you don't have the email address anywhere in the form (besides that bit of text which won't get passed to the next page..).

    <input type="hidden" name="email_address" value="<?=$email_address?>" />

    ^Put that right above your submit button. Don't need to put it in the PHP tags either with a print/echo in front of it since it still echos out the email address into the HTML with the <?=$email_address?> (which is shorthand for doing <?php echo $email_address; ?>)
     
    zerxer, Jun 14, 2008 IP
  3. ziplock122949

    ziplock122949 Active Member

    Messages:
    159
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for the help
     
    ziplock122949, Jun 14, 2008 IP