![]() |
|
|
#1
|
|||
|
|||
|
PHP: Display data of logged on person
Hi everyone, I'm creating a social network website, like MySpace or Facebook, but a simple one. I used a code I found on a website for login, register and logout. What I'm trying to do now is display member's data (like name, gender, etc) that member has registered with. So just like a profile of someone who is logged in.
This is part of the code that I have already: php Code:
php Code:
What do I need to put, so that it displays information of a person who is logged in? Can someone reply asap plz. Thank you! P.S. Sorry forgot the most important thing. This is where I got the code from: Code:
http://www.evolt.org/article/comment/17/60265/index.html |
|
#2
|
|||
|
|||
|
If you only want to show the username to the logged in user
you can add a session variable to his/her current session Code:
if (login($_POST['username'],$_POST['password']) == TRUE)
{
// User logged in. store username in session variables
session_register("username");
$_SESSION['username'] = $_POST['username'];
}
all your pages have .php extension example: <p><?php echo($_SESSION['username']); ?></p> If you want to show to all users who's online, you must make sure that active sessions will expire automatically within reasonable time. Upon login of a user, in the login table you can have a column "loggedin" and keep track of users who logged in or logged off. If a user not logs off but the session expires, I am not sure how to handle the loggedin column, but I hope it gives you an idea |
|
#3
|
|||
|
|||
|
This is the code that I use to welcome a member to each page that they view.
Code:
if (!isset($_SESSION['first_name'])) {
$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
$url = substr ($url, 0, -1);
}
$url .= '/login.php';
ob_end_clean();
header("Location: $url");
exit();
} else {
};
echo '<h1>Welcome';
if (isset($_SESSION['first_name'])) {
echo ", {$_SESSION['first_name']}!";
};
echo '</h1>';
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Data Entry Person | harjitgill | Services | 19 | Mar 15th 2009 7:18 am |
| display the certain data | kumar84 | PHP | 3 | Jul 4th 2007 6:53 pm |
| how to display data from mysql in php | luca_p7 | PHP | 2 | Sep 19th 2006 6:23 am |
| php stay logged in? | liam_d | PHP | 9 | Jan 6th 2006 2:23 pm |
| pulling data from mysql recordset and manipulating its display with php | jim_h | PHP | 2 | Nov 13th 2005 8:23 am |