If statement always false?

   <body background="image.jpg">
  <style>
      body{
          font-family: Arial, "Times New Roman";
          color:black;
      }
      input[type=text] {
  width: 30%;
  box-sizing: border-box;
  border: 2px solid #ccc;
  border-radius: 4px;
  font-size: 16px;
  background-color: white;
  background-position: 5px 5px; 
  background-repeat: no-repeat;
  padding: 12px 20px 12px 40px;
}
.button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}

  </style>

<?php


$mysqli = mysqli_connect("localhost", "user", "password", "database");

if ($mysqli == false)
{
    echo 'Not Connected to Server';
}else{
  
$ip = $_SERVER['REMOTE_ADDR'];

$statement = $mysqli->prepare('SELECT ip FROM `unbanned` WHERE ip=?');
$statement->bind_param("s", $ip);
$stmt->bind_result($selectedIp);
$stmt->fetch();



if ($ip == $selectedIp) {
    echo 'Wow you have permission to enter!';
}else {
    echo 'You dont have permission!!';
}

}
?>

This is the code that i have right now. Thanks for helping

Seems like I switched variables names half way through in my example and forgot to execute the query :blush:

It should be:


$statement = $mysqli->prepare('SELECT ip FROM `unbanned` WHERE ip=?');
$statement->bind_param("s", $ip);
$statement->execute();
$statement->bind_result($selectedIp);
$statement->fetch();
3 Likes

Thanks Much!! :slight_smile: IT WORKED I CANT BLEIVE IT WORKED THANKS MUCHH!!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.