Jump to content

making both a public and private user profile page


silverglade

Recommended Posts

Hi, I am making a dating site where I have made the user profile edit page visible to the user when they log in, and I think I can get away with not showing the user their "public" profile view. But I definitely need to show other users on the site the "public" non editing profile page view. But I don't know how to do this.

 

I have yet to create the search, search results, thumbnails with optional descriptions of the possible dating results.

 

But I first want to just get 2 versions of the user profile page view. One that the user sees that I have already done. (The editable one). And the other I need to make which is the page the other users will see, (The public profile)

 

Please if anyone has any idea how to do this I would greatly appreciate it, especially if you have any pseudocode ideas. thank you.  :D

Link to comment
Share on other sites

first thing is make a public profile page.

 

you could add a little if statement at the top of that page, that checked if user viewing profile is owner of siad profile and redirect to the editable version.

 

Alternatively you could keep both seperate and have the editable version only available from the user's menu under a button/link like my profile.

 

The important thing is to ensure that logged in user only can access their own page, and not be able to edit other users.

Link to comment
Share on other sites

thank you for that. I have come up with some pseudocode that I can't solve. Here is the little puzzle.  :D

 

 

if viewinguser= user of that page, show edit profile link, otherwise, do not.

 

I don't know how to define or check for the "viewing user" in the database or the member's page.

 

basically I am using a "viewProfile.php" page so the member can view their own profile as it looks to others, and this view profile page will only have a link back to the "edit profile" page if the current user is the owner of that page.

 

 

but please, how do I identify in code the "viewing user" to differentiate that from the "currentUser" or the owner of the page being viewed?

Link to comment
Share on other sites

................................  I have made the user profile edit page visible to the user when they log in, and I think I can get away with not showing the user their "public" profile view. But I definitely need to show other users on the site the "public" non editing profile page view. ..........

 

I'd have "one public page" with the user redirected to that page/file after editing so they can see the changes. For the user I'd have a link on his public profile or in a menu somewhere where they could click edit and go back to their edit_profile page if needed. That's simular to what I've done here Link

Link to comment
Share on other sites

thank you. Yes I figured out that I would have 2 pages, one is the public and one is the private, and the only difference between them is that the "public" will have the option of showing a link back to the "edit profile" page if the current user is the owner of the pages, but if it is a viewing member, the edit profile link on the public profile page should not be shown.

 

so basically

 

if viewinguser, don't show edit profile link, if viewinguser==currentUser, show edit profile link

 

I don't know how to do this in code, to define "viewinguser", I don't know how to do it without creating a million individual named pages like "tomsProfile.php" "JoesProfile.php", and then check if the currentUser is equal to the name on the individual page.

 

but that solution seems ridiculous and I am pretty sure there is a way to do it with  just using one changing public profile page with some simple little code, but I am not that smart yet. LOL.

 

please if anyone knows please help. thanks

Link to comment
Share on other sites

I would imagine that when a user logs in, you create some session variables to identify that user?

 

lets say im user 1, you might set $_SESSION['userid'] = '1', and when i view a page which is profile.php?ID=1 which is my profile, you have a small statement that checks if both match and if so, show an edit button, otherwise not. So if i went to profile.php?Id=2 it wouldnt show me an edit button.

however it would be good to have a another similar check on the edit profile page to ensure that it the right person editing the right profile.

 

 

Link to comment
Share on other sites

That is intelligent. great thank you very much. I didn't know how to make different users based on number id's so I am using session CurrentUser as the variable . I am using the usernames.

 

so if I have

 

$currentUser=$_SESSION['name_of_user'];

 

 

how do I make the link do this?

 

 

viewProfile.php?currentUser=thomas

assuming $currentUser=="thomas"

 

 

 

I know I should have used the user number Id but I used the unique usernames to check for identity in the

script. I don't want to change it now.

 

EDIT: this is what I have so far on the edit profile page

 

echo "viewProfile.php?user=" . $currentUser.'>View Profile</a></strong><p> </p>";

 

now I have to somehow check for that on the viewProfile.php page

 

 

Link to comment
Share on other sites

I know I should have used the user number Id but I used the unique usernames to check for identity in the

script. I don't want to change it now.

 

You could also use the mem numbers in the url and echo the user name in the header or middle column somewhere. Then just remove it when you're through testing, if you're not going to use the user name in the url and you're testing it that way when you do remove it it will be just that much more stuff to check in the php code and sql. Just a thought.

Link to comment
Share on other sites

thank you. this is what I did so far.

 

echo "viewProfile.php?user=" . $currentUser.'>View Profile</a></strong><p> </p>";

 

 

now I have to somehow check for that on the viewProfile.php page

 

not sure how to do that, googling it now. what would newbie php guys do without google? they'd be in bad shape. LOL

Link to comment
Share on other sites

can someone please help me with this link? It is not looking right in my editor every time I try to do the quotations.

 

Here it is messed up.

 

Please if someone can show me the right way to do it in code, I would really appreciate it. (The quotations)

 

echo "<a href='viewProfile.php?userPage='" . $currentUser. " >View Profile</a></strong><p> </p>";

Link to comment
Share on other sites

here is my final public and private profile code people helped me with here. IT WORKS!! HAHAH.

 

first the "edit profile page" put this in your page.

 

echo "<p> </p><strong><a href='viewProfile.php?userPage=".$currentUser."'>View Profile</a></strong><p>&nbsp</p>";
//checks if the form has been submitted
echo "<h3>EDIT PROFILE PAGE FOR ".$currentUser."</h3>";

 

then on the public profile page, put this in your page.

 

$_GET["userPage"];

if($_GET["userPage"]==$currentUser)
{
echo "<p> </p><strong><a href='profileUpload.php'".$currentUser."'>Edit Profile</a></strong><p>&nbsp</p>'";

}

 

enjoy!! thanks for helping everyone

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.