i php code which contains user login .if user logs in he can move to next page . on logout he can able to move to the index.php (which contains login.php). after logout the page should not move to previous page on click backbutton. how to create it ?
this is my logout.php
<?php
session_start();
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$_SESSION = array();
session_destroy();
session_unset();
header("location:index.php");
?>
and my index.php page has
<html><head><script>$(document).ready(function(){
$("#check_user").click(function() {
var userType=$("#userType").val();
var userEmail = $("#log_user_email").val();
var password = $("#log_password").val();
if (userEmail=="" || password=="" || userType=="select"){
alert("empty fields !!!");
}
else{
var dataString = 'userEmail='+ userEmail + '&password=' + password +'&userType='+userType;
$.ajax({
type: "POST",
url: "check.php",
data: dataString,
success: function(data) {
//alert(data);
if(data == "failure"){
alert("user name or password not valid.");
return false;
}
if(data == "success"){
alert("successfuly logged in.");
window.location='login.php';
//location.reload();
}
if(data == "already logged in"){
alert("already logged in");
location.reload();
}
}
});
}
});
});
function logout()
{
window.location='logout.php';
}</script></head>
<body><label name="email" >Email</label>
<input type="email" id="log_user_email" placeholder="example@example.com" />
<label name="password">Password</label>
<input type="password" id="log_password" placeholder="*********"/>
<input type="button" value="Login" id="check_user" onclick="check()" style="cursor:pointer;" />
<input type="button" value="logout" onclick="logout();"></body></html>