Jump to content

help get the correct user being viewed info


danjapro

Recommended Posts

The code works, only problem is. It only loads the user information, ONLY for the user that is logged in.

 

If another user ids viewed witha different userid, it DEOS NOT produce their information.

I just want the userid in url to return the information on that user, not the user logged in or user with the session ID.

 

PLESE TELL me waht to do to acheive this.

 

// Set cookie
	$userid = JRequest::getVar('userid'); 

	$data = new stdClass();
	//$model =& $this->getModel('Profile');
	//$album		= & $this->get( 'Data');
	$my = CFactory::getUser();

	// Test if userid is 0, check if the user is viewing its own profile.
	$db =& JFactory::getDBO();
	$user =& JFactory::getUser();

	// Return with empty data
	if ($user->id == null || empty($user->id)) {
	//return false;
	}

	// Query the database for the user
	$sql = 'SELECT * FROM jos_muscol_albums WHERE user_id = ' . $user->id;
	//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;

	$result = mysql_query($sql) or die('Error, No Album Search failed');
	//$result = mysql_query($sql) or die('Error, No Album Search failed<br />' . mysql_error());   

	if (mysql_num_rows($result) > 0) {
	list($id, $year, $name) = mysql_fetch_array($result);

	// Display the results
	//echo $id . '<br />' . $user->id . '<br />' . $year;
	//echo $name;




// Preform id return check and redirecto to correct url
    //$id=JRequest::getVar($prefix . 'id') ; 
	if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){
	//$url = JURI::root() . 'index.php?' . $component . '&id=' . $id . '&tmpl=component&print=1';
       $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
    for($i=1;$i<count($type);$i++){
    $url.='&'.$type[$i].'='.$layout[$i];
  }

	} else {
     $url = JURI::root() .      'index.php?option=com_muscol&view=album&id=1&tmpl=component&print=1'; 
	  }

	  } else {
	echo 'No results exist!';
	} 			
/* Creating URL */

 

  • 2 weeks later...

i don't know what framework your using, but it looks like you're not passing ANY info to the objects/functions that create the user, and which would yield the user's ID. I expected to see a $_GET['userid'] or something.

 

I'm just curious, are you trying to write this because you WANT to code your own site, or because you have no choice? I've always wonder that about people trying to do this stuff.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.