Okay I have a database with 3 ip addresses. and when I run the following code even when the table is empty still runs the same code:
fetch row model:
$whitelistip = explode(",", $usercheck->ipwhitelist);
and the code to check if the users ip address/addresses is in the row which will be stored with commas like: 123,4323,354. Yet when the database has the same ip or the row is empty the following if code always runs successfully and can't get past it :(
if(isset($whitelistip) && !in_array($_SERVER["REMOTE_ADDR"],$whitelistip)){
$date = date("F Y h:i:s");
$addlogin = $this->db->prepare("INSERT INTO logins(email,date,ip,status) VALUES(?,?,?,?)");
$addlogin->execute(array($email,$date,$_SERVER["REMOTE_ADDR"],'Unsuccessful login'));
echo '
<div class="row row-centered">
<div class="col-md-3"></div>
<div class="col-md-5">
<div class="alert alert-danger">
<strong>Oh snap!</strong> Your IP address is not on the whitelist for this account
</div>
</div>
</div>';