Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Variables from one page to another

    This seems to be such a basic thing but for some reason my brain is on lock down.

    What I want to do is this. I have two pages.
    On valve-store.php I have this select statement: valve-store.txt
    $query = "SELECT subName, subURL FROM sub_categories WHERE catId=1";

    I want to take the catId and have it equal the subId on the next page.

    On the subcategory.php page: subcategory.txt
    So I want the subId=catId so this page displays the subId that is equal to the catId from the previous page.

    I know I'm not doing this correctly and just need a little direction.

    Any suggestions or help would be greatly appreciated! Thanks!

    Here are the two pages (i put them in txt files so i could do attachments)
    valve-store.php - valve-store.txt
    subcategory.php - subcategory.txt

  • #2
    New Coder
    Join Date
    May 2009
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Easiest way is probably GET. This puts the variable onto the end of the URL like this:
    Code:
    http://site.com/page.php?var=value
    To make catId equal the subId on the next page, when you refer the user to the next page, do it like this:
    PHP Code:
    header("Location: next_page.php?catId=$catId"); 
    Then on the next page, stick this at the top:
    PHP Code:
    subId $_GET['catId']; 
    If you're passing anything you don't want the user to see easily, look into hidden fields in forms.

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

  • #4
    New Coder
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    where does this actually go?

    header("Location: next_page.php?catId=$catId");

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Where you want the information to be passed to the next page.


  •  

    Posting Permissions

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