I am facing this php header redirection issue with bootstrap, Please find the code below,
Index file:
<?php
if(!isset($_SESSION)){
session_start();
}
include("db.php");
?>
<html>
<head>
<title>
</title>
<!-- jQuery Imports
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>-->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1 /css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"> </script>-->
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js"></script>
<!-- custom Js -->
<script src="js/bookrate.js"></script>
<style type="text/css">
body{padding-top:20px;}
</style>
</head>
<body>
<div class="cycle">
<h3 class="text-center">--</h3><br>
<h2 class="text-center"><small>Admin Panel</small></h2><br>
</div>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Please sign in</h3>
</div>
<div class="panel-body">
<form id="adminLogin" method="POST">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="E-mail" name="email" type="text" id="email">
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" value="" id="password">
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me"> Remember Me
</label>
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" value="Login">
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
And My Db File is:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
?>
Ajax Admin Login Page:
<?php
OB_start();
session_start();
include("db.php");
$adminEmail =$_POST['email'];
$adminPassword = $_POST['password'];
$adminLoginQry = "select email from `users` where (email='$adminEmail') and password='$adminPassword'";
$retval = mysql_query($adminLoginQry);
if(mysql_num_rows($retval)==1)
{
header("Location: main.php");
exit;
}else{
echo "<span style='color:red;'>Please enter valid Username and Password. </span>";
}
?>
Main.php
<?php
echo "My Menu Page";
?>
Once I enter the email id and password, on click of login button both GET and POST requests are triggered, how both the requests are getting triggere I am not able to understand ?. But still Everything working fine, which I am able to confirm with Mozilla firefox firebug (developer console).
Header Location redirection is not happening to the main.php page after the login success. Please tell me what is wrong here..
This question not having answer already, for me header location is working fine, but its not working only with bootstrap 3. Please do not mark this as duplicate.