Home › Forums › Back End › Nice Profile URL? › Re: Nice Profile URL?
February 1, 2012 at 3:31 pm
#95929
Member
And the original code would need to be expanded to account for username variables too so
oh i see you want the url to change and then it to pull the correct page. Then you need to do something like the following
if (isset($_GET)) {
$id = mysql_real_escape_string($_GET);
$sql = "SELECT * FROM users WHERE id=$id";
$result = mysql_query($sql);
if (mysql_num_rows($result)==0) {
echo ('User never existed');
}
else if (mysql_num_rows($result)==1) {
$userinfo = mysql_fetch_array($result);
if (!$userinfo) {
echo ('User no longer exists.');
}
else {
$username = $userinfo;
header('Location: http://www.yoursite.com/'.$username);
}
}
}
else if (isset($_GET)) {
$uname = mysql_real_escape_string($_GET);
$sql = "SELECT * FROM users WHERE username=$username";
$result = mysql_query($sql);
if (mysql_num_rows($result)==0) {
echo ('User never existed');
}
else if (mysql_num_rows($result)==1) {
$userinfo = mysql_fetch_array($result);
if (!$userinfo) {
echo ('User no longer exists.');
}
else {
echo('Welcome to your Profile Page '.$userinfo['full name');
}
}
}
?>