pass textbox entries to another form

Discussion in 'PHP' started by tableman, Sep 23, 2006.

  1. #1
    I am trying to pass textbox entries to their namesake entries in another page, using sessions.

    In common with most other code that I write, it does not work.

    This code is in a separate file, landing_email.php:

    
    <?php
    session_start();
    global $entries;
    
    if (isset ($_SESSION['entries'])) 
    
    {$_SESSION['entries'] = $_SESSION['entries']+ 1;
    }
    else 
    {$_SESSION['entries'] = 1;
    }
    
    $_SESSION['entries']="First Name: $firstname\nLast Name: $lastname;
    ?>
    
    PHP:
    This code is in the receiving page:

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    session_start( );
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <form method="post" action="https://s.p2.webhosting.yahoo.com/forms?login=my_login" name="long_form" />
    
    <input type="text" name="firstname"  value="<?php echo $_SESSION['firstname']; ?>" />
    <input type="text" name="lastname"  value="<?php echo $_SESSION['lastname']; ?>" />
    
    Code (markup):
    This is in the first form:

    
    <form method="post" action="https://my_url.com/landing_email.php" name="life_landing" />
    <input type="text" name="firstname" />
    <input type="text" name="lastname" />
    
    Code (markup):
    Any suggestions?
     
    tableman, Sep 23, 2006 IP
  2. GuitarFix

    GuitarFix Peon

    Messages:
    37
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    wel.. but why it must work?
    you set variable $_SESSION['entries'] but not set these:
    $_SESSION['firstname']
    $_SESSION['lastname']
    Code (PHP):
    try do smth like this (landing_email.php)

    ...
    $_SESSION['firstname']=$firstname;
    $_SESSION['lastname']=$lastname;
    
    $_SESSION['entries']="First Name: $firstname\nLast Name: $lastname;"
    Code (PHP):
    it must work!
     
    GuitarFix, Sep 23, 2006 IP
  3. tableman

    tableman Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yor are correct, GuitarFix. That was a needed change.

    It does work. Thank you.

    I also needed to move:

    
    <?php session_start( ); ?>
    
    PHP:
    to the very top of the page with nothing whatever before it.

    Now it all works.

    Resolved!
     
    tableman, Sep 26, 2006 IP
  4. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Page1:
    <?
    session_start();

    $str = 13;

    session_register("str")

    ?>

    Page 2:

    <?
    session_start();
    echo $_SESSION['str'];
    ?>
     
    cancer10, Sep 27, 2006 IP