i am currently working on integrating a friend system onto my site, all has went well untill i got to the link on users profiles, my aim is to have the link appear if the user viewing the profile is not the profile owners friend, and disappear once the friend request is accepted!
Here is what i have so far in userinfo.php(profile page):
can anyone advise me where i have went wrong? as this is the final hurdle for the friend system. thanxPHP Code:<?
/* Requested Username error checking */
$req_user = trim($_GET['user']);
if(!$req_user || strlen($req_user) == 0 ||
!eregi("^([0-9a-z])+$", $req_user) ||
!$database->usernameTaken($req_user)){
die("Username not registered");
}
/* Logged in user viewing own account */
if(strcmp($session->username,$req_user) == 0){
echo "<h1>My Profile</h1>";
}
/* Visitor not viewing own account */
else{
$req_user_info = $database->getUserInfo($req_user);
echo "<br>[<a href=\"usermsg.php?username=".$req_user_info['username']."\" >Send ".$req_user_info['username']." a Message</a>] ";
echo '[<a href="mailto:'.$req_user_info['email'].'">Send '.$req_user_info['username'].' an E-mail</a>] ';
}
$get = mysql_query( "SELECT * FROM `friends` WHERE `username` = '$session->username' "); //gets friends
while ($fris = mysql_fetch_array($get))
if ($fris['friendname'] == $req_user_info['username']) { //checks if user is already a friend
echo ( "You are friends" );
}
else {
echo ( "<a href='friendrequest.php?user=$req_user_info['username']'>Add as Friend</a>");
}
echo '<h1>'.$req_user_info['username'].'\'s Profile</h1>';
}
if($req_user_info['userlevel']=='9'){
echo "<img src=\"admin_icon.jpg\" width=\"126\" height=\"21\"/><br><br>";
}
/* Display requested user information */
$req_user_info = $database->getUserInfo($req_user);
/* Username */
echo "<b>Username:</b> ".$req_user_info['username']."<br><br>";
/* Email */
echo "<b>Email:</b> ".$req_user_info['email']."<br><br>";
/* country */
echo "<b>Location:</b> ".$req_user_info['city'].", ".$req_user_info['country']."<br><br>";
/* Games */
echo "<b>My Games:</b> <font color='#003399'>".$req_user_info['games']."</font><br><br></em>";
/* About */
echo "<b>About Me:</b> <em>".$req_user_info['about']."<br><br></em>";
$timestamp = $req_user_info['timestamp'];
echo "<br><b>Last Active:</b> ".date('jS F Y \a\\t g.ia', $timestamp)." <br><br>";
/**
* Note: when you add your own fields to the users table
* to hold more information, like homepage, location, etc.
* they can be easily accessed by the user info array.
*
* $session->user_info['location']; (for logged in users)
*
* ..and for this page,
*
* $req_user_info['location']; (for any user)
*/
/* If logged in user viewing own account, give link to edit */
if(strcmp($session->username,$req_user) == 0){
echo "<br>[<a href=\"useredit.php\">Edit Profile</a>]<br>";
}
/* Link back to main */
echo "<br>Back To [<a href=\"index.php\">Main</a>]<br>";
?>



Reply With Quote

Bookmarks