php - 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
}
?>
解决方案
Initially I can see you haven't used the PHP operator for equals correctly, give this a try.
if($_SESSION['id'] == $id)
推荐阅读
- solr - Solr Suggest Component 和 OutOfMemory 错误
- ruby-on-rails - ROR: NoMethodError: nil:NilClass 的未定义方法“[]”
- google-drive-api - OS X 上的 Google Drive File Stream 无法 ls 文件
- php - 批量反转(重新利用)现有的正则表达式语句
- c - 如何从带有通配符的字符串中获取 Appx 全名?
- wordpress - WordPress 添加内联样式,如何添加 background-size 属性
- javascript - 如何在Javascript中存储特定类的对象数组?
- c++ - Nanodbc:值不适合类型字符(2)错误
- python - 具有给定索引的 numpy 元素的总和
- c# - 如何添加 WPF 按钮以将内容添加到 ObservableCollection 内的列表?