在索引页面中,用户需要登录..登录后,
<?php
include("dbinit.php");
$text="";
$eadd = $_POST['eadd'];
$pass = $_POST['pass'];
if (filter_var($eadd, FILTER_VALIDATE_EMAIL)) {
$result = mysqli_query($link,"SELECT * FROM account WHERE Eadd='".$eadd."'");
if (mysqli_num_rows($result)<=0){
$text = "<font color=red>Invalid Emailaddress and Password Combination!</font>";
}
else
{
while($row = mysqli_fetch_array($result)){
$passH = $row['Pass'];
$passS = $row['hash'];
}
if(md5($pass.$passS) == $passH){
$_SESSION['account'] = $eadd;
$text = "<font color=red>Login Successful!</font>";
}else{
$text = "<font color=red>Invalid Emailaddress and Password Combination!</font>";
}
}
mysqli_free_result($result);
} else {
$text = "<font color=red>Invalid Emailaddress!</font>";
}
mysqli_close($link);
echo $text;
?>
在索引页面中,
function login(){
var eadd = $('#eadd').val();
var pass = $('#pass').val();
$.ajax({
type: "POST",
url: "login.php",
data: {eadd:eadd, pass:pass}
}).done(function( result ) {
$("#loginMsg").html(result);
});
}
他登录后如何重定向或刷新页面?登录后,索引页面必须刷新..我需要Put window.history.pushState("", "", '/newpage'); 吗?如何使用它?