code:
<script>
$(document).ready(function(){
$("#login").click(function(event){
event.preventDefault();
elogin = $("#elogin").val();
plogin = $("#plogin").val();
$.ajax({
type:"POST",
data:{"elogin":elogin,"plogin":plogin},
url:"candidate.php",
success:function(data){
$(".login_success").html(data);
}
});
});
});
</script>
<div class="login_success"></div>
<form class="loginLay" id="myform">
<input type="text" name="elogin" id="elogin" class="form-control1" placeholder = "Enter Your Email"/>
<input type="text" name="plogin" id="plogin" class="form-control1" placeholder = "Enter Your Password"/>
<a href="javascript:void(0)" id="forgot">Forgot Password</a>
<center>
<input type="submit" name="login" id="login" class="btn btn-primary"/>
</center>
</form>
candidate.php
<?php
session_start();
include('config.php');
$email = $_POST['elogin'];
$password = $_POST['plogin'];
$sql = "select * from student where email = '$email' and password = '$password' and status = 'enable'";
$result = mysqli_query($con,$sql);
$num_rows = mysqli_num_rows($result);
if($result)
{
if ($num_rows > 0)
{
$sqls = "select * from student where email = '$email' and password = '$password'";
$results = mysqli_query($con,$sqls);
while ($rows = mysqli_fetch_assoc($results))
{
$_SESSION['student_id'] = $rows["id"];
}
header ("Location: student/dashboard.php");
}
else
{
echo "<p id='red'>Wrong email or password or may be your account not activated.</p>";
}
}
?>
I have created login form inside the bootstrap modal and wants to login using ajax but the problem is that when I click on login button it does't redirect to student/dashboard.php properly. This page i.e. student/dashboard.php are showing inside the model. I do't know why what is the problem. So, How can I redirect in student/dashboard.php ?Please help me.
Thank You