Yes, sorry i am just getting used to this thing. Thanks for pointing out the mistake.
//this will eliminate the BOT hitting up the forms
if(isset($_POST['submit_form']) && $_POST['submit_form']==session_id()){
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$query = mysqli_query("SELECT * FROM users WHERE username="$username" AND password ='$password'");
if($query==false){
set_message(" Your password or username are wrong ");
redirect("login.php");
}else{
redirect("admin");
}
}
And I updated the form as well.
<form class="form-inline" role="form" action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="form-group" for="username">username</label>
<input type="text" name="username" class="form-control" id="username" placeholder="username">
</div>
<div class="form-group">
<label class="sr-only" for="password">Password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="password">
</div>
<button type="submit" name="submit_form" class="btn btn-black">
Login
</button> <input type="hidden" name="submit_form" value="<?php echo session_id()"/>
I would use sprintf when parsing up the query. It eliminates SQL Injections. You can do something like this:
$query = sprintf('SELECT * FROM TABLE WHERE username = "%s" AND password = "%s"',
mysql_real_escape_string($username),
mysql_real_escape_string($password));
Hopefully this works for you.