Finally changing from SQL to SQLI for my login code, but a straight conversion doesn’t seem to work. Any suggestions? the database connection is separate, I have included below the action section when submit is pressed. I keep getting the message " The Username you supplied does not exist!" if that helps. The user is in the database.
<?php
if($_POST['submit']){
$username = protect($_POST['username']);
$password = protect($_POST['password']);
if(!$username || !$password){
echo "<center>Please enter your <b>Username</b> and <b>Password</b>!</center>";
}else{
$res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM `adminusers` WHERE `username` = '".$username."'");
$num = mysqli_num_rows($res);
if($num == 0){
echo "<center>The <b>Username</b> you supplied does not exist!</center>";
}else{
$res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM `adminusers` WHERE `username` = '".$username."' AND `password` = '".$password."'");
$num = mysqli_num_rows($res);
if($num == 0){
echo "<center>The <b>Password</b> you supplied does not match the one for that username!</center>";
}else{
$row = mysqli_fetch_assoc($res);
if($row['active'] != 1){
echo "<center>Your login has been <b>deactivated</b>.</center>";
}else{
$_SESSION['admin_uid'] = $row['id'];
echo "<center>You have successfully logged in!</center>";
$time = date('U')+50;
mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `adminusers` SET `online` = '".$time."' WHERE `id` = '".$_SESSION['admin_uid']."'");
<script>location.href='http://subdomain.domain.com.au/admin/login.php'</script>");
}
}
}
}
}
?>