SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    applying the spf lotion V + E + R + T's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to pass variables through multiple pages?

    So on this page www.domain.com/?a=Hello, I display the variable using <?=$Hello?>. When the user submits the form on "index.php", they get redirected to "jump.php" and then finally redirected to "final.php".

    How do I display Hello from the variable on "index.php" to display on "final.php"?
    Proud SPF member since 2001!

  2. #2
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My suggestion is do a cookie.

    if (isset($_GET["a"])){ // check if a is being sent
    $key_p=$_GET["a"];} //set the key to a
    setcookie("replicated_a", $key_p, -86400,"/",".yourdomain.com",0);//set the cookie

    Then when you are in final.php just read your cookie.

    $last_a = $_COOKIE['replicated_a'];
    echo $last_a;

    Hope that helps

  3. #3
    applying the spf lotion V + E + R + T's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sandiegotech.net View Post
    My suggestion is do a cookie.

    if (isset($_GET["a"])){ // check if a is being sent
    $key_p=$_GET["a"];} //set the key to a
    setcookie("replicated_a", $key_p, -86400,"/",".yourdomain.com",0);//set the cookie

    Then when you are in final.php just read your cookie.

    $last_a = $_COOKIE['replicated_a'];
    echo $last_a;

    Hope that helps
    Awesome, that worked like a charm! Thanks!
    Proud SPF member since 2001!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •