首页 > 解决方案 > How can I hide a button with php if it does not correspond to an id of a session?

问题描述

I am trying to hide a button if it enters a profile with an id that does not correspond to the login, that is, the user, but it does not work, how can I solve it?

 <?php
    if(isset($_GET['id']))
        {
            $id = mysqli_real_escape_string($conexion, $_GET['id']);

            $infouser = mysqli_query($conexion, "SELECT * FROM users WHERE id = $id");  
            $use = mysqli_fetch_array($infouser);
        }
    ?>

<?php

if($_SESSION['id'] = $id)
{
?>
<button class="ml-4" id="edit" data-toggle="modal" data target="#exampleModalCenter">Editar perfil</button>
<?php
}
?>

标签: phpbootstrap-modal

解决方案


Initially I can see you haven't used the PHP operator for equals correctly, give this a try.

 if($_SESSION['id'] == $id)

推荐阅读