unsider Posted March 15, 2008 Share Posted March 15, 2008 Ok. So let's assume I have three users. Tim Bob Chad They each are allowed to post comments once they have registered. Well once they post, there $_SESSION['username'] is displayed, and with it a link to their 'profile'. That's where the error is. EDIT: no error in code, just the manner in which it functions, continue reading. <?php $username = $_SESSION['username']; while($row = mysql_fetch_array($result)) { echo '<tr class="tr' . $tr . '"><td>' . '<img src="http://example.com/main/images/post.gif">' . "<a href='userinfo.php?user=$username'>" . $row["username"] . '</a>' . '<br>' . ' posted on: ' . '<br><br>' . ' ' . $row["commenttext"] . '</td></tr>'; ?> If no user is not logged in, it displays to everyone: http://example.com/main/userinfo.php?user=Guest If the user is logged in as Tim, but clicks the link to Bob's profile it displays his (Tim's) profile. And vise versa. I am trying to establish unique properties between each user, so that no matter who you are logged in as, you will be able to view that person's profile. I unfortunately do not know how to explain this, but think of this website, you can be logged on and click on someone else's profile and view their info. Ask questions if I have not clarified something correctly, otherwise, I really need help with this problem. Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted March 15, 2008 Share Posted March 15, 2008 It doesn't make since...were is the $username var getting its input? Quote Link to comment Share on other sites More sharing options...
Gamic Posted March 15, 2008 Share Posted March 15, 2008 What you want to do will not work. A Session is for one user. Since you are getting the username out of the database anyway why not use that? <?php /*$username = $_SESSION['username'];*/ while($row = mysql_fetch_array($result)) { $username=$row['username'] echo '<tr class="tr' . $tr . '"><td>' . '<img src="http://example.com/main/images/post.gif">' . "<a href='userinfo.php?user=$username'>" . $username . '</a>' . '<br>' . ' posted on: ' . '<br><br>' . ' ' . $row["commenttext"] . '</td></tr>'; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.