Jump to content

creating profile


runnerjp

Recommended Posts

ok what i got now is on profile.php

 

echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />this is your name.<br /><br />';
echo 'email <em><b><u>' . get_email ( $_SESSION['user_id'] ) . '</u></b></em>!<br />is your email.<br /><br />'; 

i used the id i had from other post to make this work

and sessions looks like this

 

// ------------------------------------------------------------------------

/**
 * Get username - Returns the username of the logged in member based on session ID
 *
 * @access	public
 * @param	string
 * @return	string/bool
 */


function get_username ( $id )
{
	global $db;

	$query = "SELECT `Username` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id );

	if ( $db->RecordCount ( $query ) == 1 )
	{
		$row = $db->getRow ( $query );

		return $row->Username;
	}
	else {
		return FALSE;
	}
}
/**
 * Get email- Returns the email of the logged in member based on session ID
 *
 * @access	public
 * @param	string
 * @return	string/bool
 */
	function get_email ( $id )
{
	global $db;

	$query = "SELECT `Email` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id );

	if ( $db->RecordCount ( $query ) == 1 )
	{
		$row = $db->getRow ( $query );

		return $row->Email;
	}
	else {
		return FALSE;
	}
} 

 

it works great obviusly when a user is logged in BUT when they are not then how can i show the users data?

Link to comment
Share on other sites

All you need do is pass your functions an id. How you get this id is up to you.

 

In the link to the example I orginally posted, there is a small script that lists all users as links to the profile.php page. That should get you a good start.

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.