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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Pulling information from a url

    I need help.
    I'm going crazy trying to figure this out.
    Here is what I am trying to do.

    Page 1- http://www.test.com/test.php?id=username
    I need to store the username in a cookie.

    Page 2- http://www.test.com/form.php
    I will have a hidden text box that needs to have the value of the cookie.
    It is so I can keep track of referrals.

    Example: user1 refers someone to my site. The id "user1" gets stored in a cookie. The visitor browses many pages on my site. If the visitor go to the sign-up form page, then a hidden text box will hold the value stored in the cookie, which should be "user1". This way when the information is sent, I can credit user1 for the referral.

    This is what I have been trying:

    On Page 1 http://www.test.com/test.php?id=user1
    <? setcookie("refer","$_GET['id']",time()+36000); ?>

    On Sign-up form page
    <input type="hidden" name="referrer" value="<? echo $HTTP_COOKIE_VARS["refer"]; ?>">

    I hope I don't confuse anyone. It's hard to explain.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome here !

    <? setcookie("refer","$_GET['id']",time()+36000); ?>

    should be

    <? setcookie('refer',$_GET['id'],time()+36000); ?>

    and best change

    <input type="hidden" name="referrer" value="<? echo $HTTP_COOKIE_VARS["refer"]; ?>">

    to

    <input type="hidden" name="referrer" value="<? echo $_COOKIE['refer']; ?>">
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you so much. It works perfectly.

    I'm actually very surprised that I wasn't too far off on my own.

    Oh well, Thanks again.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome !

    Sometimes these little things make the difference ... Glad you got it running now
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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