timmah1 Posted December 13, 2006 Share Posted December 13, 2006 I have a photo hosting site, and when the user signs up, they get their own domain, kinda like myspaceWhat I want know is, when someone types in the url of a person (ie http://www.domainname.com/user), how would PHP know to pull information associated with that user? Quote Link to comment Share on other sites More sharing options...
joquius Posted December 13, 2006 Share Posted December 13, 2006 well all you need is to get the domain name from a http request, and match that with the database information. Lets says johnnysdomain is in the url requested of your host, you look that up in the database where you inputted the domain name originally.If you notice:[code]$host_name = explode (".", $_SERVER['HTTP_HOST']); // quite lazy[/code]$host_name[0] or $host_name[1] will get you the domain name and you just have to match that to the database (key 0 may be www, ftp, etc.) Quote Link to comment Share on other sites More sharing options...
simcoweb Posted December 13, 2006 Share Posted December 13, 2006 Yup, the database query would pull the name from the url with a $_GET statement then use that info in a WHERE clause in the query. Quote Link to comment Share on other sites More sharing options...
Caesar Posted December 13, 2006 Share Posted December 13, 2006 Best way...let Apache do it. mod_rewrite for the win! Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 13, 2006 Share Posted December 13, 2006 you need a .htaccess fileand in it you would place something like this:[code]Options +FollowSymlinksRewriteEngine onRewriteRule ^(.+)/$ /user_page.php?username=$1[/code]Then in your PHP file just search the database something like this:[code]<?php $sql = mysql_query("select * FROM users where username='{$_GET['username']}' LIMIT 1"); while($row = mysql_fetch_array($sql)){ echo$row['username']; echo$row['userid']; echo$row['filename']; }?>[/code]That is just an example of how to do it, but the .htaccess file is required, and for an .htaccess tutorial, go here: http://corz.org/serv/tricks/htaccess2.php -- its one I really like. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 13, 2006 Author Share Posted December 13, 2006 ok, this still confuses meWhen someone signs up, their username is their domain.If the url that somebody types in ishttp://www.domain.com/mysiteHow would the site now to pull all the information for the user 'mysite'? Quote Link to comment Share on other sites More sharing options...
joquius Posted December 13, 2006 Share Posted December 13, 2006 $array = explode ("/", $_SERVER['HTTP_REQUEST']);$user = $array (count ($array) - 1); // extremely lazythis is if it's a "shared" domain, with a directory/page Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 14, 2006 Author Share Posted December 14, 2006 ok, i'm a dumb ass.I didn't mean to say their own 'domain', the get their own 'directory', which is a alot differenthttp://www.domainname.com/directoryHow would I pull the username from just typing in the address the url?The username will always be the directory, in this example, the username is 'directory'I'm trying to understand this, but for some reason it's not sticking Quote Link to comment 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.