php mysql如何检查用户是否是个人资料的所有者或者只是一个查看者

时间:2013-05-05 00:43:35

标签: php mysql jquery

我正在创建一个具有添加好友系统的个人资料页面,我必须检查用户是个人资料的所有者还是仅查看者。如果他是所有者,他不能向他人发送请求,否则他可以发送请求。

但问题是系统始终显示用户是个人资料所有者,这是不正确的,并且不允许我发送请求。

个人资料.php

<?php


//check if the logued in user is diffrenet from the url username 
if($username!=$login_user)
{
    $interactionBox='<div class = "InteractionLinksDiv">
    <a href= "#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'add_friend\');">Add as Friend</a>
    </div>';
    $isOwner = "no";
}
//check if the logued in user is equal from the url username
else
{
    $interactionBox='<div style="display:inline; border:#CCC 1px solid; padding:5px; background-color:#E4E4E4; color:#999; font-size:11px;">
    Other members will see  links to interact with you here.
    </div>';
    $isOwner = "yes";
}
?>

//  function to add friend recive 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?&nbsp;

               <a href ="#" onclick="return false" onmousedown="javascript:addAsFriend(<?php echo $_SESSION['user_id']; ?>,<?php echo $userid; ?>);">Yes</a>
               </div>

0 个答案:

没有答案