Jump to content

Viewing other people's profile in php


jd2007

Recommended Posts

member.php?userid=member_userid

so you need to check if the $_COOKIE['registered'] = $_GET['userid'], then show the edit button

on the edit page check if the profile you want to edit = $_COOKIE['registered'], if not redirect, if yes, show the page

Link to comment
Share on other sites

Without having any idea of how your code currently works, its all going to be a bit difficult to say how you shoud do this. How are you storing the users profiles? Do you set sessions when someone logs in?

 

Typically, you would have two pages. One would be something like editprofile.php. The other, viewprofile.php.

 

editprofile.php would get the current user's profile from a database. You would search for their profile based on which user is currently logged in. Something like:

 

<?php
$user = $_SESSSION['user'];//presumably you are setting some sessions on login
//here you would check to see if a form has been posted to a page, if so, check the new profile and update the databse
$sql = mysql_query('SELECT `profile` FROM `users` WHERE `user`='$user'");
$profile = mysql_result($sql,0,"profile");
echo "<textarea name='profile'">$profile</textarea>";
//the rest of your form
?>

 

Whislt viewprofile.php would be something like:

 

<?php
$id = $_GET['id'];//you would pass the id of the person's profile you want to look at through the url
//e.g. viewprofile.php?id=123
$sql = mysql_query('SELECT `profile` FROM `users` WHERE `userid`='$id'");
$profile = mysql_result($sql,0,"profile");
echo $profile;
?>

 

 

Its quite difficult to give anything definitive here. It all depends on how you are already doing things.

 

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.