Hello,
I am trying to make the code below work so that when a member visits his/her own profile they can see the $bank_balance along with all the other details. However, when the member goes and visits someone elses profile I dont want them to be able to see the profile members $bank_balance.
I am only learning PHP so am not that great at knowing whats what. lol
The $userid and $username is a global setting that identify's the member and I have managed to get it to work so that when a member visits his/her own profile they can view their bank balance.
However, when that member goes to another members profile they still see their own bank balance which isnt what I require. Instead I want the field $bank_balance and the text to disappear when not at their own.
Can anyone help? It would be much appreciated
Thank you
Justin
Here is the snippet of code:
if ($membersprofiles[username]= $username)
{
$bank_balance = $bank[bank_balance];
}
This is the full document!
<?php
/*
User Profile (user_profile.php)
*/
$rank_check = 1;
$page_title = "User Profile";
include "header.inc.php";
$members = fetch("SELECT * FROM members2 WHERE username = '$user' AND game = '$game'");
$members_profiles = fetch("SELECT * FROM members_profiles2 WHERE username = '$user' AND game =
'$game'");
$bank = fetch("SELECT * FROM bank WHERE owner_id ='$userid'");
$online = fetch("SELECT last_visit FROM online WHERE userid = '$members[id]' ORDER BY last_visit
DESC LIMIT 1");
if ("$members_profiles[username] == '$members[username]'") { $change_profile .= "<p align=center><a
href=http://cyberpetworld.com/update_profile.php?game=1>
<font size=4 face=Arial>Edit My Profile</font><font face=Arial color=#0000FF size=4>
</font></a><font face=Arial color=#0000FF size=4> | </font>
<font color=#000000 face=Arial><font size=4>
<a style=text-decoration: underline href=http://cyberpetworld.com/mystuff.php?game=1>
My Control Panel</a></font></font></p> "; }
if ($rank >= "60")
{
$iplog = fetch("SELECT ip_addr FROM ip_log WHERE userid = '$members[id]' ORDER BY id DESC
LIMIT 1");
$membersIP = " ($iplog[ip_addr])";
}
if (!$members[id])
{
die("$openHTML<p align=center class=error><center><p><br>That is not a real
user</p>$closeHTML");
}
if ($members[rank] <= 1)
{
die("$openHTML<p align=center class=error><center><p><br>This user has been
suspended.</p>$closeHTML");
}
if ($membersprofiles[username]= $username)
{
$bank_balance = $bank[bank_balance];
}
$munny = $members[points];
$experience2 = $members[exp_points];
$gender = $members_profiles[gender];
$genderArray = array("<img src=images/icons/undecided.gif>", "<img src=images/icons/female.gif>",
"<img src=images/icons/male.gif>");
$gender = $genderArray[$gender];
$mailSettings = $members_profiles[mail_settings];
$mailSettingsArray = array(
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"<a href=mail_send.php?game=$game&send_to=$usersOn[username]><img src=images/icons/mail.gif></a>",
"");
$mailSettings = $mailSettingsArray[$mailSettings];
$bud = "<a href=buds.php?game=$game&bud=$members[username]><img src=images/icons/bud.gif></a>";
$date_registered = date("M j, Y", $members_profiles[date_registered]);
$last_visited = date("H:i", $online[last_visit]);
$last_visited2 = date("M j, Y @ H:i", $online[last_visit]);
$exBday = explode("-", $members_profiles[birthday]);
$months = array("", "January", "February", "March", "April", "May", "June", "July", "August",
"Septemeber", "October", "November", "December");
$bdayMonth = $exBday[0];
if ($bdayMonth < 10) { $bdayMonth = ereg_replace("0", "", $bdayMonth); }
$exBday[0] = $months[$bdayMonth];
$birthday = "$exBday[0] $exBday[1], $exBday[2]";
$userAge = $this_year - $exBday[2];
if ($this_month < $exBday[0])
{
$userAge = $userAge - 1;
}
if (($this_month == $exBday[0]) AND ($today < $exBday[1]))
{
$userAge = $userAge - 1;
}
if ($online[last_visit] >= ($timestamp - $secondsToKeepUsersOn))
{
$onlineNow = "<b><font color=green>Yes! <i><br><font size=-1><font color=black>Last visit
at</font color><font color=green> $last_visited</font></i></font></b>";
}
else
{
$onlineNow = "<B><font color=red>No <i><font size=-1><br><font color=black>Last visit
on</font color><font color=green> $last_visited2</font></i></font></b></font></b>";
}
$yourNotes = fetch("SELECT bud_note FROM buds2 WHERE bud_me = '$userid' AND bud_you = '$members
[id]'");
$yourNotes = $yourNotes[bud_note];
if (!$yourNotes) { $yourNotes = "<i>You do not have any notes on the player, add them to your buddy
list to add notes!</i>"; }
$find_shop = fetch("SELECT shop_name,shop_size FROM usershops2 WHERE owner = '$members[id]' AND
game = '$game'");
if ($find_shop[shop_name])
{
$usershop_line = "<b>Shop:</b> </b><a href=$base_url/usershop.php?
game=$game&user=$user>$find_shop[shop_name]</a> <font size=-1>(size $find_shop[shop_size])</font>";
}
$find_gallery = fetch("SELECT gallery_name,gallery_size FROM usergallerys WHERE owner = '$members
[id]' AND game = '$game'");
if ($find_gallery[gallery_name])
{
$gallery_line = "<b>Gallery:</b> </b><a href=$base_url/usergallery.php?
game=$game&user=$user>$find_gallery[gallery_name]</a> <font size=-1><font color=black>(size
$find_gallery[gallery_size])</font>";
}
$locationLine = $members_profiles[location];
if (!$locationLine)
{
$locationLine = "<i>Middle of no where!</i>";
}
$getClub = fetch("SELECT position,club FROM club_members2 WHERE user = '$members[id]' AND game =
'$game'");
$getclub = fetch("SELECT id,name FROM clubs2 WHERE id = '$getClub[club]' AND game = '$game'");
if ($getclub[id])
{
$clubrank = $getClub[position];
if ($clubrank == 1)
{
$position = "Member";
}
if ($clubrank == 2)
{
$position = "Moderator";
}
if ($clubrank == 3)
{
$position = "Admin";
}
$club_line = "<b>Club:</b><font color=black></b> $position in <a href=$base_url/club.php?
game=$game&clubid=$getclub[id]>$getclub[name]</a>";
}
$findPets = mysql_query("SELECT id,name,level FROM user_pets2 WHERE owner = '$members[id]' AND
adoption = '0' AND game = '$game'");
$numUserPets = mysql_num_rows($findPets);
$x = 1;
while ($getPets = mysql_fetch_array($findPets))
{
if ($x < $numUserPets)
{
$petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a>
(Lvl. $getPets[level]), ";
}
else
{
$petList .= "<a href=user_pets.php?game=$game&id=$getPets[id]>$getPets[name]</a>
(Lvl. $getPets[level])";
}
$x++;
}
echo <<<END
$openHTML
<head>
<script type="text/javascript">
<!--
function BUDS() {
window.open( "http://www.cyberpetworld.com/buds.php",
"BUDS",
"status = 1, height = 500, width = 500, resizable = 0, scrollbars=1" )
}
//-->
</script>
</head>
<div align="center">
<center>
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0"
width="770" bgcolor="#ffffff" border="0">
<tbody>
<tr>
<td width="757">
<p align="center"><font color="green" size="-1"><font color="green"><font style="font-size: 11pt"
face="Verdana">$change_profile </font></font></font></p></td></tr>
<tr>
<td width="757">
<center>
<p><strong><br />
<font style="font-size: 20pt" face="Verdana" color="#006699"><img height="85" alt="" width="85"
src="uploads/$members_profiles[avatar_selected]" /> <font size="+2"><strong>$members[display_name]'s House</strong></font></center>
<center>
<hr width="75%" color="#00e000" /></center></font></strong></td></tr>
<tr>
<td width="757"><font size="-1">
<p style="margin-top: 0px; margin-bottom: 0px"> </p>
<div align="left">
<table style="border-collapse: collapse" bordercolor="#111111" height="1" cellspacing="0"
cellpadding="0" width="764" border="0">
<tbody>
<tr>
<td width="27" height="14"></td>
<td width="133" height="14"><font face="Century Gothic" color="#006699"><strong><font style="font-
size: 11pt">Username:</font></strong></font><font style="font-size: 11pt" face="Century Gothic"
color="green"></strong> </font></td>
<td width="328" height="14"><font face="Tahoma">$members[display_name]</strong><font style="font-
size: 9pt">$membersIP</font></font></td>
<td width="276" height="1" rowspan="7">
<div align="center">
<center>
<table style="border-collapse: collapse" bordercolor="#9999ff" height="59" cellspacing="0"
cellpadding="0" bgcolor="#dfdfff" border="1">
<tbody>
<tr>
<td align="middle" width="200" colspan="2" height="23"><strong><font face="Arial"
size="1">OPTIONS</font></strong></td></tr>
<tr>
<td align="middle" width="100" height="35">
<form method="post" action="mail_send.php?game=$game&send_to=$members[username]"><input
type="submit" value="Send Mail" /> </td>
<td align="middle" width="100" height="35"> <input type="button" value="Add Me" onClick="BUDS
()" /></td></tr></tbody></table></center></div></td></tr>
<tr>
<td width="27" height="15"></td>
<td width="133" height="15"><font face="Century Gothic" color="#006699"><strong><font style="font-
size: 11pt">Real name:</font></strong></font><font style="font-size: 11pt" face="Century Gothic"
color="green"></strong></font></td>
<td width="328" height="15"><font face="Tahoma">$members_profiles[real_name]</font></td></tr>
<tr>
<td width="27" height="3"></td>
<td width="133" height="3"><font style="font-size: 11pt" color="green"><strong><font face="Century
Gothic" color="#006699">Birthday:</font></strong><font face="Century Gothic"> </font></font></td>
<td width="328" height="3"><font face="Tahoma">$birthday </font></td></tr>
<tr>
<td width="27" height="3"></td>
<td width="133" height="3"><font style="font-size: 11pt" color="green"><strong><font face="Century
Gothic" color="#006699">Experience:</font></strong><font face="Century Gothic"> </font></font></td>
<td width="328" height="3"><font face="Tahoma">$experience2</font></td></tr>
<tr>
<td width="27" height="11"></td>
<td width="133" height="11"><strong><font face="Century Gothic"
color="#006699">Location:</font></strong> </td>
<td width="328" height="11"><font face="Tahoma">$locationLine </font></td></tr>
<td width="27" height="5"></td>
<td width="133" height="5"><font color="green"><strong><font style="font-size: 11pt" face="Century
Gothic" color="#006699">Date Registered:</font></strong></font></td>
<td width="328" height="5"><font face="Tahoma">$date_registered</font></td></tr>
<tr>
<td width="27" height="1"></td>
<td width="133" height="1"><font color="green"><strong><font style="font-size: 11pt" face="Century
Gothic" color="#006699">Total Referrals:</font></strong></font></td>
<td width="328" height="1"><font face="Tahoma">$members_profiles[referrals] </font></td></tr>
<tr>
<td width="27" height="1"></td>
<td width="133" height="1"><font color="green"><strong><font style="font-size: 11pt" face="Century
Gothic" color="#006699">Total Posts:</font></strong></font></td>
<td width="328" height="1"><font face="Tahoma">$members[post_count] </font></td></tr>
<tr>
<td width="27" height="1"></td>
<td width="133" height="1"><font color="green"><strong><font style="font-size: 11pt" face="Century
Gothic" color="#006699">Bank Balance:</font></strong></font></td>
<td width="328" height="1"><font face="Tahoma"><font color= "red">$bank_balance <font color="black"
size="2">munny</font></td></tr>
<tr>
<td width="27" height="12"></td>
<td width="133" height="12"></td>
<td width="328" height="12"></td>
<td width="276" height="12"></td></tr>
<tr>
<td width="27" height="15"></td>
<td width="737" colspan="3" height="15">
<table style="border-collapse: collapse" bordercolor="#111111" height="43" cellspacing="0"
cellpadding="0" width="740" border="0">
<tbody>
<tr>
<td width="274" height="16"><font color="black"><font color="black" size="-1"><font size="-1"><font
face="Tahoma" color="#006699" size="2"><strong>$numUserPets Pets:</strong> </font><font
face="Tahoma" size="2">$petList</font></font></font></font></td>
<td width="466" height="16"><strong><font color="black"><font face="Tahoma" color="#006699"
size="2">$usershop_line</font></font></strong></td></tr>
<tr>
<td valign="top" width="274" height="27"><font color="black"><font color="green" size="-
1"><strong><font face="Tahoma" color="#006699" size="2">$club_line
</font></strong></font></font></td>
<td valign="top" width="466" height="27"><font color="black"><font color="green" size="-
1"><strong><font face="Tahoma" color="#006699"
size="2">$gallery_line</font></strong></font></font></td></tr></tbody></table></td></tr>
<tr>
<td width="27" height="1"></td>
<td width="737" colspan="3" height="1">
<p style="margin-top: 0px; margin-bottom: 0px"><font face="Tahoma" color="#006699"
size="2"><strong>Your Notes:</strong> </font><font face="Tahoma"
size="2">$yourNotes</font></p></td></tr>
<tr>
<td width="27" height="12"></td>
<td width="737" colspan="3" height="12"></td></tr>
<tr>
<td width="27" height="19"> </td>
<td width="737" colspan="3" height="19"><font color="green" size="-1"><font face="Tahoma"
color="#006699" size="2"><strong>Online Now?
$onlineNow</strong></font></font></td></tr></tbody></table></div><font face="Tahoma"
color="#006699" size="2"><strong>
<center>
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td></td></tr></tbody></table></center></strong></font></font></td></tr>
<tr>
<td align="middle" width="757">
<div align="center">
<center>
<table style="border-collapse: collapse" bordercolor="#111111" height="56" cellspacing="0"
cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td width="100%" height="37">
<p align="center">
<center>
<p style="margin-top: 0px; margin-bottom: 0px">
<iframe style="overflow: hidden" frameborder="0" width="650" height="300" src="ajax-chat-
multi/cyberpet.php?room=$members[display_name]s+House"></iframe></center></td></tr>
<tr>
<td width="100%" height="19"> </td></tr></tbody></table></center></div></td></tr>
<tr>
<td width="778">
<p align="center"></p></td></tr></tbody></table></center></div>
<div align="center">
<center>
<table style="border-collapse: collapse" bordercolor="#111111" height="78" cellspacing="0"
cellpadding="0" width="888" border="1">
<tbody>
<tr>
<td width="886" height="78">
<p style="margin-top: 0px; margin-bottom: 0px" align="left"><font color="green"><strong><font
face="Century Gothic" color="#006699"> About Me</font></strong>
<div align="center">
<center>
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0"
width="830" border="0">
<p>
<tbody>
<tr>
<td width="100%"><font style="font-size: 11pt" face="Verdana">$members_profiles[profile]
<p>
<center>
<p></font></center></p></td></tr></table></center></div>
<p align="left"> <strong><font face="Century Gothic" color="#006699">Interests &
Hobbies:</font></strong> </p>
<p align="center">
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0"
width="830" border="0">
<p>
<tbody>
<tr>
<td width="100%"><font style="font-size: 11pt" face="Verdana">$members_profiles[interests]
<p>
<center>
<p></font></center></p></td></tr></table>
<p align="left"> <strong><font face="Century Gothic" color="#006699">Likes and
Dislikes:</font></strong> </p>
<p align="center">
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0"
width="830" border="0">
<tbody>
<tr>
<td width="100%"><font style="font-size: 11pt" face="Verdana">$members_profiles[hobbies]
<p>
<center>
<p></font></center></p></td></tr></tbody></table>
<p align="left"><strong><font face="Century Gothic" color="#006699"> Favourite Films / Books /
Muisc:</font></strong> </p>
<p align="center">
<table style="border-collapse: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0"
width="830" border="0">
<tbody>
<tr>
<td width="100%"><font style="font-size: 11pt" face="Verdana">$members_profiles[hobbies]
<p>
<center>
<p></font></center></p></td></tr></tbody></table></font></font></font></p>
<p align="center">$change_profile </p></td></tr></tbody></table></center></div></form>
$closeHTML
END;
?>