我对通过 jQuery 的 AJAX POST 有疑问。这是客户端代码:
$.ajax({
url: 'php/registration_and_login/login.php',
type: 'post',
data: {saveConection: saveConection, loginEmail: loginEmail, loginPass: loginPass }
}).always(login);
这是PHP代码:
<?php
include '../functions/connection.php';
$link = conenct('localhost', 'root', '', 'w_db');
$saveConection = $_POST['saveConection'];
$loginEmail = $_POST['loginEmail'];
$loginPass = $_POST['loginPass'];
$loginEmail = mysql_real_escape_string($loginEmail);
$loginPass = mysql_real_escape_string($loginPass);
$saveConection = mysql_real_escape_string($saveConection);
$emailResult = mysql_query("SELECT COUNT('id') FROM users WHERE userEmail = '$loginEmail' AND userPass = '$loginPass'") or die('Invalid query:'. mysql_error());
$validation = mysql_result($emailResult, 0);
if($validation) {
$query1 = mysql_query("SELECT id FROM users WHERE userEmail = '$loginEmail'") or die('Invalid query:'. mysql_error());
$tmp = mysql_fetch_assoc($query1);
$id = $tmp['id'];
session_start();
$_SESSION['id'] = $id;
if($saveConection == 'yes'){
setcookie('login', $loginEmail);
setcookie('password', $loginEmail);
}
echo "true";
}
else {
echo "false";
}
?>
我收到此错误:
注意:未定义索引:第5行C:...\login.php中的 saveConection
在我看来, 的 POST 没有问题saveConection
,我也找不到问题所在。