We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,394 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

User Profile Pages

I have already created profile pages, but they can only be seen by the person who is logged in. How can I make them public so that other people can view them?

Basically I want to make it so that if the user is logged in, they can edit their profile, and if they are not, they can view their profile (and other people's profile pages)

2
Contributors
1
Reply
1 Hour
Discussion Span
1 Year Ago
Last Updated
2
Views
greenelf
Newbie Poster
1 post since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Well it looks as though you've set up your system to protect profiles from users who have not logged in. All you need to do if something like this:

Get user ids and usernames from DB:

<a href="www.example.com/profile.php?id=231">ardav's profile</a>
<a href="www.example.com/profile.php?id=706">greenelf's profile</a>

The in your profile.php page:

if(isset($_GET['id'])){
    $edit = false;
    $id = intval($_POST['id']);
    if(isset($_SESSION['login_id']) && $id == $_SESSION['login_id']){
        $edit = true;
    }
    $result = ... (etc)
}

Now you can control the output based on the value of $edit.

diafol
Keep Smiling
Moderator
10,672 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0562 seconds using 2.68MB