0

Ajax 関数 POST または GET を介して Ajax_mysql.php を呼び出すファイル index.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;
}
?>
4

1 に答える 1