-2

我有一个可供多个用户访问的页面。每个人登录,一个 PHP 页面查找用户并验证该人。这也可以提取有关用户等级的信息。如果等级等于 1a 或 1b,我想禁用附加的搜索按钮,其他人都可以。我有其他 javascript 禁用了 DIV,但我无法让它在这里工作。

    <div id="footer" style="background-color:#3399cc;clear:both;text-align:center;"><font  color="#000099">DJR</font>
    <a href="change.php"class="buttons">Change password</a>
    <a href="out.php" class="buttons">Logout</a>
    <a href="search.php" class="buttons">Search</a>
    <a href="Calendar.php" class="buttons">Calendar</a>
    <a href="AL.php" class="buttons">Leave</a>
    </div>

这就是我获取有关当前用户的信息的方式!

  $fgmembersite->userID();

如果这等于除 1a 和 1b 之外的任何值,则启用它。再次提前感谢,在这个网站上总是有很大的帮助。

4

3 回答 3

2

为什么要向用户显示禁用的按钮?只需回应他们可以使用的那些。

<?php 
  if(($fgmembersite->userID() == '1a') || ($fgmembersite->userID() == '1b')){
    echo '
      //echo buttons allowed to 1a and 1b users (or nothing at all)
    ';
  }
    else{
      echo '
        //echo buttons not allowed to 1a and 1b users (or nothing at all)
      ';
    }
?>
于 2012-12-10T13:31:09.310 回答
0

下面的伪代码可以帮助你

<a href="search.php" class="buttons" <?php if(//users grade is 1a or 1b) { ?> onClick="return false;" <?php } ?> >Search</a>
于 2012-12-10T13:14:16.573 回答
0

用这个

<?php
    <a href="search.php" class="buttons"<?php if( $fgmembersite->userID()<>'1a' or  $fgmembersite->userID()<>'1b'  ){
echo " disabled='disabled' ";
}?>>Search</a>
?>
于 2012-12-10T13:07:15.203 回答