每次我尝试从我的文件 index.php 中发布或使用 get,它通过 Ajax 函数 POST 或 GET 调用 Ajax_mysql.php,我都会不断收到内部 500 错误。服务器没有给出除此之外的任何其他错误。我已经包含了调用服务器端 php 的 javascript 函数。
function submit_login() {
if( document.form.loggedIn.checked ) return
request = new XMLHttpRequest()
request.onreadystatechange = respond_login
request.open("POST", "Ajax_mysql.php", true)
request.send( "action=login&password=" + postEscape( document.form.pwd.value ) +
"&username=" + postEscape( document.form.user.value ))
document.form.pwd.value = ""
document.form.user.value = ""
}
PHP Ajax_mysql.php:
<?php
$password_test = "fcb";
$username_test = "ben";
$action = $_POST['action'];
$username = $_POST['username'];
$password = $_POST['password'];
//Testing against hardcoded username and password
if ($username != $username_test)
{
//output the response
$response = "failed"
echo $response;
}
?>