Jump to content

profile site


runnerjp

Recommended Posts

hey guys.... wunderd if someone could point me in right direction.... im making a profile site so each person has there on profile page

 

what would be the best way to have the users have there own page if that makes sense?

 

so my profile page would be www.mywebpage.com/admin

 

 

Link to comment
Share on other sites

in your .htaccess

RewriteEngine  on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/?$ profile.php?username=$1 [L]

 

in your profile.php

$username = $_GET['username'];
//query DB for the username and get the user id

 

this should get you started :)

Link to comment
Share on other sites

but why would i want to use it as www.mywebpage.com/profile.php?username=admin  ????

 

you don't need to use it...it's just how it works, the .htaccess converts it to that without you actually seeing it...but thats how the php reads it.

Link to comment
Share on other sites

Why not just use something like this?

 

profile.php

 

<?php

$username = $_GET["username"];

$q = mysql_query("SELECT * FROM users WHERE username = '$username'");
$r = mysql_fetch_assoc($q);

echo "Welcome to ".$username."'s profile page.";

?>

 

Very basic but it will work :)

Link to comment
Share on other sites

But the solution I've already given you makes it work with new accounts without doing anything. They type "/username" and get taken to their page which is (secretly) found at /profile.php?user=username.

 

It's foolproof and means you don't physically make them a page.

Link to comment
Share on other sites

.htaccess

 

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/\.]+) profile.php?user=$1 [nc]

 

profile.php

 

<?php

echo $_GET['user'];

?>

 

 

ok so would i put this in a new file called profiles or something to keep it seperate yes

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.