I'm currently making a simple login system with PHP and when write this
$sql = "SELECT * FROM logintoken WHERE token ='".$_COOKIE['SNID']."';";
it didn't give any result, eventhough when I echo out $_COOKIE['SNID'], it spitted out correct result. I also checked the database, the value was there in the 'token' row.So how can I fix this problem. Thank you for reading this text. Here is my Code:
<?php
if(isset($_COOKIE['SNID'])){
echo 'Logged in';
echo '<form action="logout.weg.php" method="post">
<button type="submit" name="logout">Press to logout</button>
</form>';
$userid = $_COOKIE['SNID'];
$sql = "SELECT * FROM logintoken WHERE token ='".$_COOKIE['SNID']."';";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result) > 0){
while ($row= mysqli_fetch_assoc($result)){
echo $row['user_id'];
}
} else {
echo 'No result';
}
} else {
echo 'Not logged in';
}
?>