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 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts

    $_GET + MySQL [Visitors/Referred]

    OK. Pretty much I am looking for a tutorial on taking a variable in the browser, (EX: google.com?r=123) and adding 1 (Yes, like the number) to 123's referral count. If anyone can direct me on how to do that, that'd be wonderful

    ALSO, is there a way where we can do it with a line of code simply like:
    PHP Code:
    $referrals[123] = ++; 
    Or something? So the user has to do something for it to go up?

    Blockis

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    yes, you can use HTTP_REFERER:

    PHP Code:
    $_SERVER['HTTP_REFERER']; 
    then you'll need to parse the query string to get the data, at that point you should be able to increment the number like:
    PHP Code:
    $value++; 

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    It's as easy as $_GET['r']++. Now, if you want that new number to show up in the URL, you'll need to reload the page. You can do this with a header("Location:URL"), but you'll need to format the query string yourself. You can also use a form with method="GET", then use a hidden input element to handle the the new number.

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah, thanks for the spam.......

    ( does this ever actually work? )

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    We're now engaged.

  • #6
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    sweet! if only I had clicked sooner!


  •  

    Posting Permissions

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