我正在使用jQuery发布一个php文件,我得到了500个内部服务器文件,为什么


I am using jQuery to post a php file, I am getting 500 internal server file, Why?

我正在构建一个jQuery文件来验证用户在wordpress网站上登录的输入。 我已经制作了检查wordpress数据库中用户名,电子邮件和密码的功能。 我的功能非常适合用户名和电子邮件,但是使用密码功能,我收到 500 内部服务器错误。 我唯一能想到的会导致这种情况的是我试图包含来自 wordpress 的三个文件。 我必须使用 class-phpass.php 来检查密码,因为密码被散列然后存储到数据库中。 class-phpass.php 文件有一个名为 CheckPassword 的函数,它将散列密码与纯文本密码进行比较,如果它们匹配,则返回 true,如果不匹配,则返回 false。 我还包含了 wp-settings.php 和 wp-load.php,只是想让我的 php 文件为我的验证工作。

我正在创建这个,以便如果用户输入错误的用户名或密码,他们不会被从我的灯箱登录名中带走。

这是我的jQuery函数来检查密码:

jQuery.post("/wp-content/themes/Landing/includes/check_password.php", {password:pWd2, email:email},
            function(data){
                if( data == '1' )
                {
                    CheckPassword = true;
                }else{
                    //show that the password is NOT available
                    alert("The password and/or username you have entered is incorrect!");
                    CheckPassword = false;
                }  
            });

更新!!!::

好的,我让我的 php 文件正常工作,我的 jQuery.post 正常工作。但是,我现在遇到了逻辑错误。 我正在使用 chrome 工具并逐步执行代码,我需要将 false 返回到表单以防止网页刷新/重定向。 提交我在这里的检查后,它似乎逐步完成了函数(数据):

if (CheckUsername == false){
        return false;
    }
    if (CheckPassword == false){
        return false;
    }
    else{
        return true;
    }

它会在进入 post 函数之前检查 ^ ^ 该代码块,如果密码不正确,则将密码查核设置为 false。

此行应该建立与数据库的连接:

$connection = mysqli_connect("databaseAddress", "login", "password", "table"); //creates a database connection

" DatabaseAddress "不是有效的数据库地址,其他选项可能也不是。您必须填写这些凭据。使用 Wordpress 时,一些常量在 wp-config.php 中定义。试试这一行:

$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); //creates a database connection