version 1.1Everything what is needed is:
config.php - from 4images
.htaccess file (must be in folder where who.php will be)
who.php (you can name it how you want)
now no test needed, just set your url and try it. I`ve tested it only on my server.
will work only with this link
http://your_url/who/user namenot with
http://your_url/who/user name/.htaccess<files *>
Options MultiViews
</files>
who.php<?
// Settings
///////////////////////////////////////////
$url = "http://www.pramoga.net";
$table = "4images_users"; //do not edit if you have not changed table prefix
// Code
///////////////////////////////////////////
include "config.php";
$a_url = $_SERVER["REQUEST_URI"];
$i = explode("/", $a_url);
$b = count($i);
$b = $b-1;
$i = str_replace(array("%20"), " ", $i[$b]);
if (($i != "") and ($i != "guest"))
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error");
@mysql_select_db("$db_name", $db) or die ("DB not found");
$result = mysql_query("SELECT user_id FROM `$table` WHERE user_name='$i'");
$row = mysql_fetch_array($result);
$id = $row['user_id'];
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id."");
}
else
{
header("Location: ".$url."");
}
?>
version 1Just a little script that I made for my site
A personal addres for users, to profile.
DEMO:
http://www.pramoga.net/who/admin/ (
admin is user name, existing in 4images gallery)
So, first I want to explain how it works
"
who" is not a folder, it`s originaly a script called who.php, to use this script without extension .php you will need to put .htaccess file into the folder where who.php is. The code of .htaccess is:
<files *>
Options MultiViews
</files>
So the first thing is done
Second is very important for script who.php and it depends on your url, how many slashes "/" there is. I made a little test to find out what number for variables you will need.
test.php
<?
$url = "http://www.pramoga.net"; //your url
$url_extender = $_SERVER["REQUEST_URI"];
$all_url = $url.$url_extender;
print_r(explode("/", $all_url));
?>
Change url in this script and go to it like that
http://www.pramoga.net/test/admin (can be another user name)
or
http://www.pramoga.net/test.php/admin (can be another user name)
DEMO:
http://www.pramoga.net/test/adminWe need a number of user name, So we take it from here
Array (
- => http: [1] => [2] => www.pramoga.net [3] => test.php [4] => admin )
The number is 4
We can go to final step
Script who.php
<?
/////////////////////////////////////////////
// Originaly made for http://www.pramoga.net
// If you made any modifications, feel free
// to contact with me and share your code ;)
/////////////////////////////////////////////
$url = "http://www.pramoga.net";
/////////////////////////////////////////////
include "config.php";
$url_extender = $_SERVER["REQUEST_URI"]; // gets url end
$all_url = $url.$url_extender; // i dont know why, but i make all url...
$i = explode("/", $all_url); // then I delete all slashes
$i = $i[4]; // when I get array of symbols, I take fourth symbol (it depends on url)
$i = str_replace(array("%20"), " ", $i); // replaces %20 with simple space " "
if (($i != "") and ($i != "guest")) //if url is with name and it`s not guest
{
$db = mysql_connect("$db_host", "$db_user", "$db_password") or die ("Error"); // connecting to db
@mysql_select_db("$db_name", $db) or die ("DB not found"); // selecting db
$result = mysql_query("SELECT user_id FROM `4images_users` WHERE user_name='$i'"); //querying mysql, and selecting users id from db
$row = mysql_fetch_array($result);
$id = $row['user_id']; //selected id seting to variable $id
//finally
header("Location: ".$url."/member.php?action=showprofile&user_id=".$id.""); //setting header location to members profile
}
else //if no name was given
{
header("Location: ".$url.""); //setting header location to index page
}
// thats all :)
?>
Find $i[4];
and change 4 to your number, that you find in test.php
It`s explained step by step, so it`s very simple
Upload it to the server and try