0
I have a login system and I wanted it to appear ERROR if the user is banned. The SQL name in the table is "ban", if "ban" equals "0" the user will not be banned, and if "ban" equals "1" the user will be banned and cannot log in.
Code:
<?php
@$username = $_POST['username'];
@$password = $_POST['password'];
$passwordcrip = md5($password);
if((!$username) || (!$password)) {
echo "";
} else {
$passwordcrip = md5($password);
$sql = mysql_query("SELECT * FROM usr_users WHERE username='{$username}' AND password='{$passwordcrip}'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$key = stripslashes( $val );
echo "";
}
$_SESSION['id'] = $id;
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$_SESSION['credits'] = $credits;
mysql_query("UPDATE usr_users SET ultimo_log = now() WHERE id ='{$id}'");
header("Location: index.php");
}
} else {
echo "<div class='right' style='background: rgb(173, 2, 2);width: 100%;height: 50px;line-height: 50px;background-repeat: no-repeat;padding-left: 30px;color: white;'>
Dados incorretos, tente novamente.
</div>";
}
}
?>