silverglade Posted February 22, 2012 Share Posted February 22, 2012 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. Quote Link to comment Share on other sites More sharing options...
spiderwell Posted February 22, 2012 Share Posted February 22, 2012 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. Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 thank you for that. I have come up with some pseudocode that I can't solve. Here is the little puzzle. 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? Quote Link to comment Share on other sites More sharing options...
floridaflatlander Posted February 22, 2012 Share Posted February 22, 2012 ................................ 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 Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 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 Quote Link to comment Share on other sites More sharing options...
spiderwell Posted February 22, 2012 Share Posted February 22, 2012 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. Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 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 Quote Link to comment Share on other sites More sharing options...
floridaflatlander Posted February 22, 2012 Share Posted February 22, 2012 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. Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 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 Quote Link to comment Share on other sites More sharing options...
trq Posted February 22, 2012 Share Posted February 22, 2012 what would newbie php guys do without google? they'd be in bad shape. LOL Or they would learn to *think*. Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 using google does not equal someone not being able or not wanting to think. Have you ever used Google? yes you have. Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 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>"; Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 maybe this is right? echo "<a href='viewProfile.php?userPage='. $currentUser. '>View Profile</a></strong><p> </p>'"; LMAO!! I think this is the right one. echo "<p> </p><strong><a href='viewProfile.php?userPage=".$currentUser."'>View Profile</a></strong><p> </p>"; Quote Link to comment Share on other sites More sharing options...
silverglade Posted February 22, 2012 Author Share Posted February 22, 2012 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> </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> </p>'"; } enjoy!! thanks for helping everyone 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.