Example #1
0
<?php

header("Content-Type: application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:POST,GET");
require_once "./Db.php";
require_once "./Response.php";
$username = Response::_post('username');
$userpass = Response::_post('userpass');
if (!isset($username) || !isset($userpass)) {
    Response::show(400, '输入的数据不正确');
} else {
    $connect = Db::getInstance()->connect();
    $sql = "select * from users where user_name='" . $username . "'and user_psd='" . $userpass . "'";
    $result = mysql_query($sql, $connect);
    if (!mysql_num_rows($result)) {
        Response::show(400, '输入的用户名或密码不正确');
    } else {
        $results = mysql_fetch_assoc($result);
        Response::show(200, 'success', $results);
    }
}