I am trying to have a website with login page but every time I enter the email and password i get "wrong credentials". followings are my codes, first my html code:
<form class="form-login" action = "check.php">
<div class="errorHandler alert alert-danger no-display">
<i class="fa fa-remove-sign"></i> You have some form errors. Please check below.
</div>
<fieldset>
<div class="form-group">
<span class="input-icon">
<input type="text" class="form-control" name="user" placeholder="Username">
<i class="fa fa-user"></i> </span>
</div>
<div class="form-group form-actions">
<span class="input-icon">
<input type="password" class="form-control password" name="pass" placeholder="Password">
<i class="fa fa-lock"></i>
<a class="forgot" href="#">
I forgot my password
</a> </span>
</div>
<div class="form-actions">
<label for="remember" class="checkbox-inline">
<input type="checkbox" class="grey remember" id="remember" name="remember">
Keep me signed in
</label>
<button type="submit" class="btn btn-green pull-right" name="btn-login"> Login <i class="fa fa-arrow-circle-right"></i></button>
then my check.php code:
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['user'];
$mypassword=$_POST['pass'];
echo "$myusername";
$sql="SELECT * FROM $tbl_name WHERE email='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file
session_register("myusername");
session_register("mypassword");
header("location:.index2.html");
}
else {
echo "Wrong credentials!";
}
and here is my first row of table: admins table
and I exactly enter Korivand.neshat@gmail.com as a username and 123456789 as a password in the related fields.