SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Sep 2002
    Location
    Downunder
    Posts
    541
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Newbie PHP question, passing variables between pages

    Basically have a home page with five options to go to a sub page. Depending on what is clicked on the sub page will extract different records from a MySQL database.

    What is the format to call a sub php script and pass it a variable. And while on the subject how can you pass multiple variables (as an array or something).

    TIA

  2. #2
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    make the link subpage.php?variable=blah

    in subpage.php get the information "blah" by using $_GET['variable']

    for multiple ones just do

    subpage.php?variable=blah&something=blah&somethingelse=blah
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Or you could use sessions. Just at the top of each page make a call to session_start() and whenever you want to store something in the session, do this
    PHP Code:
    $_SESSION['key'] = "something you'd love to pass between pages"


    Sessions are more secure and the end user can't just change the querystring to try and pass fake variables to your script.
    Last edited by DJ P@CkMaN; Feb 22, 2004 at 23:07.

  4. #4
    SitePoint Addict Mower's Avatar
    Join Date
    Feb 2004
    Location
    Aussie Aussie Aussie
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Noob question? what is the code to get the variable back out the session id?

    Mower


    "Will I ever find my way to GURU?"

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    session_start();
    echo( 
    $_SESSION['key'] ); 

  6. #6
    SitePoint Addict Mower's Avatar
    Join Date
    Feb 2004
    Location
    Aussie Aussie Aussie
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool thanks


    "Will I ever find my way to GURU?"


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
  •