I have an issue that I made a php code and I made a registration system, now, I have successfully made a user page which is like ( ?id=1 )
But if I view ?id=2 it still shows data for user id=1 (me) How can i solve that?
And how can i hide the Edit profile button for userid2 if I am not userid2 ?
PHP:
<? session_start(); include 'db.php'; $iDD = $_SESSION['id']; ?> <a href="home.php?id=<?php echo $iDD;?>">edit user Login</a><br><br> <?php $DOO = $_GET['id']; $SEL= $con->prepare("SELECT * FROM users WHERE id=:id"); $SEL->execute(array( 'id' => $iDD )); $data = $SEL->fetchall(); foreach ($data as $row){ echo "your username:".$row['user']."<br>"; echo "your user password:".$row['pass']."<br>"; echo "your user id:".$row['id']."<br>"; } ?>
Change as follows;
$SEL->execute(array(
'id' => $DOO
));
You can use an if statement like this:
<?php if ($iDD == 1): ?>
<a href="home.php?id=<?php echo $iDD;?>">edit user Login</a><br><br>
<?php endif ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.