Hello,

I have created a website with register, login and logout features where the user information is stored in a mysql database. I have already setup a profile page where the user can edit his/her profile but I need to know how I can make it so any member can see a different members profile?

If anyone could help, it would be greatly appreciated, thanks.

what u did so far?

I've done registration, login, logout and profilepage where the user can change information. I don't know how to go about making it so each user has a seperate page where other users can see their chosen public information

You can create 2 pages.
1) list all members with pagination, with id link to there profile page
2) profile view page (same as you profielpage u did for modifying, but only text no html elements)

Ok, I understand what to do but how to do it is a different matter lol. Would I need to create each page individually with a different file name as each different ID? If not how do I make it create the page for each member?

no as i said only two page

like you see daniweb
it has web develpment topics, you can seee list of around 20 topics then on next page next 20.

If you lick on title of topic this page loaded
so basically there are only 2 pages, one for listing another for vieewing

you just pass userid to the second page and in ur query, u filter records on the base of passed userid

first page

<a href='mem_profile.php?uid=1> Memeber 1<a>
<a href='mem_profile.php?uid=2> Memeber 2<a>
<a href='mem_profile.php?uid=3> Memeber 3<a>
<a href='mem_profile.php?uid=4> Memeber 4<a>

second page (mem_profile.php)

select * from table where userid='{$_GET['uid']}'

display record of uid clicked

Yay! it works :D Thanks

One more question though, is there a way I could list all the members by their username with a bit of php?

select username,id from members

<a href='members_profile.php?id=<?php echo $row[id];?> >' > <?php echo $row[username];?> </A>

I have a noob question, what do I need to assign to $row?

I get this error:

C:\xampp\htdocs\CodeForums\members\memberList.php on line 10

Notice: Undefined variable: row in C:\xampp\htdocs\CodeForums\members\memberList.php on line 10
>' > 
Notice: Use of undefined constant username - assumed 'username' in C:\xampp\htdocs\CodeForums\members\memberList.php on line 10

Notice: Undefined variable: row in C:\xampp\htdocs\CodeForums\members\memberList.php on line 10

write code here, not error

<?php
    session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<a href='members_profile.php?id=<?php echo $row[ID];?> >' > <?php echo $row[username];?> </a>
</body>
</html>

you have to open mysql connection, you have to write query and you have to keep link in loop

Oh yeh I forgot to open the connection xD What query do I need to write? & What you mean by keep link in loop?

(Soz, I'm confused right now)

Ok so now I have a memberList page displaying all members using this code:

<?php
        while($row = mysql_fetch_array($result))
        {
            echo "<a href='members_profile.php?id=<?php echo $row[0];?>' >" .$row['username'] . ', ';
        }
?>

but if I click on the user Admin it goes to this 'page':
/members_profile.php?id=<?php%20echo%209;?>

And it can't find the page (I don't think thats right is it^^?) but the code I have in the mem_profile is:

<?php
    session_start();

    Connected to database here

    $sql = "select * from users where username='{$_GET['uid']}'";
?>

Shouldn't this:

<?php
        while($row = mysql_fetch_array($result))
        {
            echo "<a href='members_profile.php?id=<?php echo $row[0];?>' >" .$row['username'] . ', ';
        }
?>

Be this:

<?php
    while($row = mysql_fetch_array($result))
    {
     echo '<a href="members_profile.php?id=' .$row[0]. '">' .$row['username']. '</a>';

    }
?>

Also, with this code:

<?php
    session_start();

    Connected to database here

    $sql = "select * from users where username='{$_GET['uid']}'";
?>

Be very careful about just passing in $_GET params through queries, it's really bad. Store it in a variable and perform validation on it.

Hope this helps :)!

Member Avatar for iamthwee

You've got php tags within php tags, this is a no no.

Ah thank you so much everyone, got it working now :D Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.