user profile url's www.example.com/user1

Hi, I am creating a membership website. So far I have gotten to the point were the person can register to my website.

They enter there username, password, firstname and lastname.

The firstname and lastname can be seen on the profile.php page when hey login for there eyes only, but I want them to be abl to have a user profile like this:

www.example.com/user1

How can I do this?

This is what goes on there profile.php page when a user is logged in:

[php]echo "Welcome to your profile “; echo $_SESSION[‘valid_user’]; echo " !!!”;
echo “


”;
// localhost database Access Info

$host = ‘webhost.com’;
$user = ‘111’;
$pass = ‘0111111’;
$db = ‘111’;

//connect to database
$conn = mysql_connect($host,$user,$pass) or die(“cant open the connection”);
mysql_select_db($db) or die(“could not select db”);

//run the query
$query = “SELECT city, firstname,lastname FROM authorised_users WHERE name=’”.$_SESSION[‘valid_user’]."’";
$result = mysql_query($query) or die(“error in $query query” . mysql_error());

//get the results as an array
$row = mysql_fetch_assoc($result) or mysql_error();

echo “

”;
// print firstname
echo "Your First Name: "; echo $row[‘firstname’];
echo “

”;
// print lastname
echo "Your Last Name: "; echo $row[‘lastname’];
echo “

”;
// print city
echo "City: "; echo $row[‘city’];[/php]

Set a get vairble on the link and then store on a variable and then just conect to db retrieve the information
let me know if u see example if im not clear

you did not have the courtesy of saying thanks on your previous thread:

http://www.phphelp.com/forum/index.php?topic=17674.new#new

Im sorry, I went back and said thank you. For some reason it wasn’t letting me reply. Could you show me an example of this? Thanks!!

The way that i Know is having AN url like this :
www.mydomain.com/?user= user1

if it is okay with that read on

[php]
if (isset($_GET[‘user’]))
{
$user = $_GET[‘user’];
…/// now variable user contains user1 which is name of an user you can use to fetch data from database where username = $user
}
[/php]

Im very confused on what this means or even were to begin on implementing this. Can you help me? Thanks!!!

first of all.
u dont mind having an url like this www.mydomain.com/?user=wilson382?

where wilson382 in the url will be my username to access my profile

Thats 110% fine with me. I don’t mind that at all.

where are display all the user profile information? on your index or a separate file?

if it is on your main index.

right on your code where you are going to display the user info you can check if ?user=username
you check if it is set if it is set you will et information from database according to that variable
[php]
if (isset($_GET[‘user’]))
{
$user = $_GET[‘user’];
…/// now variable user contains user1 which is name of an user you can use to fetch data from database where username = $user

}
[/php]

All of the user profile information is stored in the database. Right now, the only one who can see their information is the user logged in.

so if tommy1 logs in and goes to profile.php he can see the information “Firstname” and “Lastname” from when he registered through the register form. Same for any other user who logged in. They simply see the information they put into the database.

I want them to actually have user profiles that can be seen publicly.

so user can only see their profile if they are logged in ? OR if they have the public URL?

If a user is logged in, they can see their info on profile.php.

I want this to be public by typing in www.website.com/user

Sponsor our Newsletter | Privacy Policy | Terms of Service