I have my site and everyday i look at the log files , yesterday i saw that someone try to inject this code into the admin panel, here is the code for my panel :
<html>
<body>
<center>
<form action="login.php" method="POST">
username <input type="text" name="name">
password <input type="text" name="pass">
<input value="submit" type="submit" name="go">
</form>
</center>
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '*****');
define('DB_DATABASE', '******');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
$user = $_POST['name'];
$pass = $_POST['pass'];
if(isset($_POST['go']))
{
$sql = "select * from users where username = '$user' AND password = '$pass' ";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
//$active = $row['active'];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
header("location: a22.php");
}else {
echo $error = "<center>"."Your Login Name or Password is invalid"."</center>";
}
}
?>
</body>
</html>
and the code that someone tried to inject it is :
admin ' OR '1'='1
AND he left the password blank
so can this code make him bypass the authentication process ? even if he/she left the password blank ??
Note: the admin user is valid and have id =1 in my db ;