dongzj2015 2016-10-25 08:59
浏览 39
已采纳

当有3个会话时,检查会话和更改菜单

How can I code $_SESSION to have three possible conditions?

These are the three possible types of conditions, the session can be student, corporate and institute:

if($_SESSION['user_id'] && $_SESSION['user_type']=="student"){
else if($_SESSION['user_id'] && $_SESSION['user_type']=="corporate"){
else if($_SESSION['user_id'] && $_SESSION['user_type']=="institute"){

If any of those sessions are there I want to show a profile buttons else a register button.

<?php if(isset($_SESSION())){?>
<a href="my-profile.php"><input type="button" value="VISIT YOUR PROFILE"></a>
<?php }else{ ?>
<a href="signup.php"><input type="button" value="REGISTER NOW"></a>
<?php } ?>
  • 写回答

3条回答 默认 最新

  • dongshang1529 2016-10-25 09:28
    关注

    I think this is what you are trying to accomplish:

    if($_SESSION['user_type']=="student" || $_SESSION['user_type']=="corporate" || $_SESSION['user_type']=="institute") {
        echo '<a href="my-profile.php"><input type="button" value="VISIT YOUR PROFILE"></a>'; 
    }
    else {
        echo '<a href="signup.php"><input type="button" value="REGISTER NOW"></a>';
    }
    

    If user_type is student, corporate or institute they will be able to visit their profile through the available button. Anyone else will see the register button.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!