1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with passing variables

Discussion in 'PHP' started by alterman, Dec 11, 2008.

  1. #1
    I have two different pages.
    I need to pass stored 2 variables to another page & when a second page will redirect me back to first page, insert back the variables.

    Thank you!
     
    alterman, Dec 11, 2008 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can use session variables:

    session_start();
    $_SESSION['var1'] = $var1;
    $_SESSION['var2'] = $var2;

    those variables will be available on any page as long as the session is started. Or you can use get variables:

    page.php?var1=something&var2=somethingelse

    which would then be visible via:

    $_GET['var1'] and $_GET['var2'] respectively
     
    GreatMetro, Dec 11, 2008 IP
  3. RRWH

    RRWH Active Member

    Messages:
    821
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    70
    #3
    both methods given will work - but using get to pass values is pretty silly from a security perspective.
     
    RRWH, Dec 11, 2008 IP
  4. farad

    farad Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Page1 :
    <?php
    session_start();
    $_SESSION['yourvariable1'] = $yourvalue1;
    $_SESSION['yourvariable2'] = $yourvalue2;
    ?>
    PHP:
    Page2 :
    <?php
    session_start();
    $variable1 = $_SESSION['yourvariable1'];
    echo $variable1;
    ?>
    PHP:
     
    farad, Dec 12, 2008 IP
  5. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    We weren't talking about security, we were talking about passing variables from one page to another.
     
    GreatMetro, Dec 12, 2008 IP