Abdul Waheed Abdul Waheed - 2 months ago 10
MySQL Question

check session and change menu when 3 sessions are possible

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 } ?>


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.