How to make a script that takes 2 form fields from page 1 and introduce them in page2

Discussion in 'Programming' started by fluor, Jun 28, 2010.

  1. #1
    How to make a script that takes 2 form fields from page 1 and introduce them in page ?

    It is kind of login script, for example:

    Page 1:
    Login name: A
    Country: USA
    Button(to go to next page)

    Page 2:
    Login name: A
    Country: USA
    Name
    Age
    Etc...

    Note that pages are different and php.

    Thanks for future help

    Regards,
    Fluor
     
    fluor, Jun 28, 2010 IP
  2. Mibunal

    Mibunal Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Starting a session would be the best choice here but if there's no need for the user to go back and forth, use POST method.
     
    Mibunal, Jun 28, 2010 IP
  3. supra shoes

    supra shoes Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Maybe it is right.
     
    supra shoes, Jun 28, 2010 IP
  4. fluor

    fluor Active Member

    Messages:
    571
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Can you give me an example of POST method, i don`t really understand how to do this:)

    Thanks for help!

    Regards,
    Fluor
     
    fluor, Jun 28, 2010 IP
  5. skyfe

    skyfe Active Member

    Messages:
    256
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    63
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Like:

    page1.html

    
    <form mehod='POST' action='page2.php'>
    <input type='text' name='username'>
    <input type='text' name='country'>
    ...
    <input type='submit' name='submitPage1'>
    </form>
    
    HTML:
    page2.php
    
    <?php
    if($_POST['submitPage1']) {
    
    $username = $_POST['username'];
    $country    = $_POST['country'];
    
    ?>
    <b>Username:<b> <?=$username;?> <p>
    <b>Country:</b>  <?=$country;?>
    <?php
    }
    ?>
    
    PHP:
    And if you need it to remain forever, you can make a session like

    
    $_SESSION['loggedin'] = TRUE;
    
    PHP:
    Once the user is loggedin or whatever needs to be remembered and then check it like:

    
    if($_SESSION['loggedin'] == TRUE) { //user loggedin
     //...
    }
    
    PHP:
     
    skyfe, Jun 28, 2010 IP
    fluor likes this.
  6. fluor

    fluor Active Member

    Messages:
    571
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6

    This is what i looked for. THanks for help!!
     
    fluor, Jun 28, 2010 IP
  7. Dangy

    Dangy Well-Known Member

    Messages:
    841
    Likes Received:
    25
    Best Answers:
    2
    Trophy Points:
    155
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #7
    You don't need to use sessions, it is actually better to use the $_GET['id''] functions and call the information from the url!, you can also encrypt the url code after it's all been gathered into 1 url display! Then use the $_GET functions on the next page to display the data in hidden fields or call it out if needed! then on submit process all the information! The best and secure way of doing this! You can also use .htaccess mod rewrite to even increase the security of the encoded url by not allowing it to be displayed at all.

    Reason this is a better secure way:

    Sessions are stored on to the users computer via a Session Cookie! Which can be high jacked from hackers etc. With the method above everything is done on your server and is as secure as your encryption is! Which things can be encrypted, in a un-reverse way. Making this the most secure method on doing this!
     
    Dangy, Jun 28, 2010 IP