I want to redirect the page after login succesfully completed. but the problem in this code is, if i give wrong input, it also go to home page. so i removed this statement 'window.location = home.php'. what could i do now? does anyone help me guys?
<script>
$(document).ready(function(){
$('#reg_form').parsley();
$('#reg_form').on('submit',function(event){
event.preventDefault();
if($('#reg_form').parsley().isValid())
{
$.ajax({
url:"db.php",
method:"POST",
data:$(this).serialize(),
beforeSend:function(){
$('#submit').attr('disabled','disabled');
$('#submit').val('submitting the value');
},
success:function(data){
$('#reg_form')[0].reset();
$('#reg_form').parsley().reset();
$('#submit').attr('disabled',false);
$('#submit').val('submit');
$('#message').html(data);
}
});
}
});
});
</script>
db.php
<?php
//user login
if(isset($_POST['email']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$query = "SELECT * FROM tbl_register where email ='$email' AND password = '$password'";
$result = mysqli_query($connect,$query);
if(mysqli_num_rows($result)>0)
{
echo "login successfully completed";
}
else
{
echo "login failed";
}
}
?>