Pulling information from a url
Moderator: General Moderators
Pulling information from a url
Example:
url: http://www.test.com/test.php?id=username
How can I display just the username on the page of this website.
url: http://www.test.com/test.php?id=username
How can I display just the username on the page of this website.
yeah you are most correct mark (as always)
that dont pertain to me (i should really think about how others code n not about my methods.) all my variables are check with if statements made into an array so I can display all possible errors at once before they are assigned to vars.
But if you dont do that, marks way would most definately be the best solution.
that dont pertain to me (i should really think about how others code n not about my methods.) all my variables are check with if statements made into an array so I can display all possible errors at once before they are assigned to vars.
But if you dont do that, marks way would most definately be the best solution.
You guys have been really helpful. I have one more question.
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.
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.
This worked for me:
Code: Select all
if (!empty($_GET['foo'])) {
setcookie("CookieName", $_GET['foo'], time()+3600);
}Code: Select all
<input type="hidden" name="referrer" value="<?php echo $_COOKIE['CookieName']; ?>">