我正在使用以下代码将 imag 文件保存在机器上,如果用户是真实的,则保存图像,否则应显示注册页面。但是在保存图像页面后刷新或身份验证失败未重定向到注册。问题是什么?
js ajax ::
$.ajax({
type: "POST",
url: "userLoginAction.php",
data: {image: dataURL,uname:uname,pwd:pwd}
}).done(function( respond ) {
alert("Downloading Completed"+respond);
console.log('back on download js**');
});
PHP userLoginAction.php ::
<?php
include("sessionHandler.php");
include("../connect.php");
$con = connectDb();
$db = SelectDB($con);
$username = $_REQUEST['uname'];
$password = $_REQUEST['pwd'];
$img= $_POST['image'];
// To protect MySQL injection
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query = "SELECT * FROM user WHERE user_email ='".$username."' AND user_password='".$password."'";
$result = mysql_query($query);
$count=mysql_num_rows($result);
if($count==1){
// Register $myusername, $mypassword and redirect to file
createLoginSession($username,$password);
include 'download.php';
}
else {
echo "Wrong Username or Password".$img;
header("location:signup.php");
}
?>