I tried this code to use for login but it does not work. when I click on submit, nothing happens. When I tried to login I am always getting a wrong password error, but my password is correct. what should I do?
my HTML
<form class="form-horizontal" id="loginform" method="post">
<div class="form-group">
<label for="userid" class="col-sm-3 control-label">User ID</label>
<div class="col-sm-9 has-feedback">
<input type="text" class="form-control" id="userid" name="userid" placeholder="Enter Your User ID" required>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Password</label>
<div class="col-sm-9 has-feedback">
<input type="password" class="form-control" id="password" name="password" placeholder="Enter Your Password" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
</div>
<div class="form-group">
<div class="col-xs-4 col-xs-offset-8">
<button type="submit" id="submit" class="btn btn-danger btn-block btn-flat">Sign In</button>
</div>
</div>
</form>
my Php
<?php
$userid = security($_POST['userid']);
$password = security($_POST['password']);
$query = mysqli_query($link,"SELECT * FROM user WHERE USER_USERNAME = '".$userid."' AND USER_PASSWORD = '".$password."'");
$numrows = mysqli_num_rows($query);
if ($numrows!==0)
{
while($row = mysqli_fetch_assoc($query))
{
@$_SESSION['session_userid'] = $row['USER_USERNAME'];
@$_SESSION['session_accounttype'] = $row['ACCESS_ID'];
}
//Location Depends on the User Type
if($_SESSION['session_accounttype']=="1")
{
echo 'true';
}
}
else
{
echo 'false';
}
?>
My JS
$(document).ready(function(){
$("#add_err").css('display', 'none', 'important');
$("#submit").click(function(){
username=$("#userid").val();
password=$("#password").val();
$.ajax({
type: "POST",
url: "../basefunction/login.php",
data: "userid="+username+"&password="+password,
success: function(html){
if(html=='true') {
//$("#add_err").html("right username or password");
window.location="admin";
}
else {
$("#add_err").css('display', 'inline', 'important');
$("#add_err").html("<img src='images/alert.png' />Wrong username or password");
}
},
beforeSend:function()
{
$("#add_err").css('display', 'inline', 'important');
$("#add_err").html("<img src='images/ajax-loader.gif' /> Loading...")
}
});
return false;
});
});