コード例 #1
0
ファイル: login.php プロジェクト: joyme123/html
<?php

require_once "db/db_account_class.php";
if (isset($_Cookie['username'])) {
    echo '{"login_status":"success"}';
} else {
    $username = $params['username'];
    $passwd = $params['password'];
    $data = array();
    $account_db = new CDBAccount();
    if (!$account_db) {
        exit;
    }
    $accountinfo = null;
    $accountinfo = $account_db->queryAccountInfoByUsernamePasswd($username, $passwd);
    if (count($accountinfo) > 0) {
        setCookie("username", $accountinfo[0]['username'], time() + 60 * 60 * 24 * 30);
        $accountinfo[0]["login_status"] = "success";
        echo json_encode($accountinfo[0]);
    } else {
        echo '{"login_status":"failed"}';
    }
}