我在检查用户是页面所有者还是仅查看者时遇到问题,因为如果他是所有者,则他无法发送好友请求,因此系统始终显示查看者始终是所有者。我该如何解决这个问题?
profile.php
// function to add friend receive 2 arguments
function addAsFriend(a,b)
{
//alert("Member with id:" + a + "request friendship with the memeber with id:" + b);
var url = "script_for_profile/request_as_friend.php";
$("#add_friend").text("please wait...").show();
$.post(url,{request:"requestFreindship",mem1:a,mem2:b},function(data){
$("#add_friend").html(data).show().fadeOut(12000);
});
}
<div class="interactContainers" id="add_friend">
<div align="right">
<a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('add_friend');">Cancel</a>
</div>
Add <?php echo $username ?> as Friend?
<a href ="#" onclick="return false" onmousedown="javascript:addAsFriend(<?php echo $_SESSION['user_id']; ?>,<?php echo $userid; ?>);">Yes</a>
</div>
请求_as friend.php
if($mem1==$mem2)
{
echo "Error you can not add yourself as a friend";
exit();
}