Jump to content

URL Question


timmah1

Recommended Posts

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.)
Link to comment
https://forums.phpfreaks.com/topic/30545-url-question/#findComment-140605
Share on other sites

you need a .htaccess file
and in it you would place something like this:
[code]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)/$ /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.
Link to comment
https://forums.phpfreaks.com/topic/30545-url-question/#findComment-140615
Share on other sites

ok, i'm a dumb ass.

I didn't mean to say their own 'domain', the get their own 'directory', which is a alot different

http://www.domainname.com/directory

How 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
Link to comment
https://forums.phpfreaks.com/topic/30545-url-question/#findComment-141149
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.