php - Checking if two results are the same not working -
so i'm trying display message user of account. i'd go user profile /index.php?username=joe
. if joe
you'd have ability of post, i'd show post box. issue reason box shows if you're not joe
. here's code
$stmt = $con->prepare("select username users username = :username"); $stmt->bindvalue(':username', $_get['username']); $stmt->execute(); $row = $stmt->fetch(); $username = $row['username']; if (count($username) < 1){ echo "user not found"; } echo $_session['user']; echo $username; ?> //issue has here somewhere <?php if($_session['loggedin'] == true || $username == $_session['user']) : ?> <form method="post" action="http://localhost:8888/post/p.php"> <input type="text" name="post" placeholder="post"> <input type="submit"> </form> <?php else: ?> <!--display sign , in--> <p>sign in </p> <?php endif; ?>
so echo $_session['user'];
displays allen, while echo $username;
displays joe. i'd assume form shouldn't show. ideas?
you using wrong operator. ||
means logical or
.
<?php if($_session['loggedin'] == true || $username == $_session['user']) : ?>
instead need logical and
:
<?php if($_session['loggedin'] == true && $username == $_session['user']) : ?>
Comments
Post a Comment