voxxtelum Posted January 30, 2008 Share Posted January 30, 2008 I am designing a site that has a referral system and I want to create a URL that the users receive once they sign up. I want the referral link to look like www.url.com/x where x is their user id. I know how to create a referral link using GET, but the URL would look something like www.url.com/index.php?refid=x and I want something simpler than that. Any help would be greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/ Share on other sites More sharing options...
aebstract Posted January 30, 2008 Share Posted January 30, 2008 www.url.com/index.php?refid=x then use something like echo "$_GET['refid']"; That will echo "x", I don't really know what you want to do with the refid but that's how you get it so that you can use it. Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453789 Share on other sites More sharing options...
voxxtelum Posted January 30, 2008 Author Share Posted January 30, 2008 Thanks for the quick response and I am sorry if I was unclear with my original question. I know how I can retrieve variables from the URL using GET, I just don't know how to get the id from the URL when it looks like www.url.com/x. For example if member1 signs up and his user id is 1, then I want the referral link to look like www.url.com/1. How can I get the 1 from the URL so that I can use it to know who referred him? Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453794 Share on other sites More sharing options...
aebstract Posted January 30, 2008 Share Posted January 30, 2008 You mean so you know who he refers? You would still use the $_GET? If you want to know how match it up to which user that id is set as, you would have to check your database for a user with that id. Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453799 Share on other sites More sharing options...
laffin Posted January 30, 2008 Share Posted January 30, 2008 U have to check if yer server supports PATH_INFO, if not ya may have to edit .htaccess to make a ReWrite Rule Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453800 Share on other sites More sharing options...
atlanta Posted January 30, 2008 Share Posted January 30, 2008 You need to google .htaccess mod_rewrite rule to do that heres an example Add that line to .htaccess with your values in the page.php part RewriteEngine On RewriteRule ^([0-9]+) /page.php?member=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453803 Share on other sites More sharing options...
voxxtelum Posted January 30, 2008 Author Share Posted January 30, 2008 Thanks to all that replied so soon. I am unable to try the rewrite rule now but I will later tonight and post back if I have a problem. I am hosting with bluehost and I'm pretty sure that mod_rewrite is supported. Quote Link to comment https://forums.phpfreaks.com/topic/88624-url-question/#findComment-453816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.