Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在两个数据库中执行ajax验证?一个是API数据库,另一个是本地数据库_Ajax_Codeigniter - Fatal编程技术网

如何在两个数据库中执行ajax验证?一个是API数据库,另一个是本地数据库

如何在两个数据库中执行ajax验证?一个是API数据库,另一个是本地数据库,ajax,codeigniter,Ajax,Codeigniter,在我的视图中,我的控制器函数中有一个典型的用户名和密码输入表单 public function login() { $username = $_POST['username']; $password = md5($_POST['password']); //if user dont exist in the in the local database it will be validated thru the API if(!$this->is_regist

在我的视图中,我的控制器函数中有一个典型的用户名和密码输入表单

public function login() {
    $username = $_POST['username'];
    $password = md5($_POST['password']);
    //if user dont exist in the in the local database it will be validated thru the API
    if(!$this->is_registered_email($_POST['username'])) {
        $ret = file_get_contents('http://www.XXXXd48170846c1e937640ae7e9f6743089c3c2a9074/auth/{"user":"' . $username . '","pass":"' . $password . '"}');
        $ret = json_decode($ret);
    } else {
        //this is where if the user exist in the local database and in the API database
        // and if the user input a wrong password

    }
    //this will return user details from the API if the user exists
    $data = array('response' => $ret);

}

我在流程中添加了注释

为什么在javascript验证服务器端进行中继。因为页面不应该使用ajax重新加载,但我说的是验证服务器端。我认为服务器端验证是您应该做的