Example #1
0
function check_username_password($username, $password, &$ret_token)
{
    $ret = null;
    $mysqli = mysqli_new();
    $sql = "select * from manager where name='root' and password='******'";
    $sql = "select * from users where username='******'and password='******'";
    $result = mysqli_obj_query($mysqli, $sql);
    if (is_null($result) || 1 != $result->num_rows) {
        $ret = "username or password was not right";
    } else {
        require_once "./session.php";
        update_session($username);
        while ($row = mysqli_fetch_assoc($result)) {
            //echo json_encode($row);
            $token = md5(uniqid(rand()));
            $ret_token = $token;
            $sql = "INSERT INTO `loginStatus`(`username`, `token`) VALUES ('{$username}', '{$token}')";
            $result = mysqli_obj_query($mysqli, $sql);
            $ret = "ok";
            break;
        }
    }
    /* free result set */
    //$result->free();
    $mysqli->close();
    return $ret;
}
Example #2
0
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<?php 
require_once "../db/conn.php";
if (isset($_POST["submit"]) && $_POST["submit"] == "Signup") {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    if ($username == "" || $password == "" || $email == "") {
        echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
    } else {
        #mysql_query("set names 'gdk'");
        $sql = "select * from users where username='******'";
        $result = mysqli_obj_query(mysqli_new(), $sql);
        $num = $result->num_rows;
        if ($num) {
            echo "<script>alert('用户名已存在'); history.go(-1);</script>";
        } else {
            $sql = "INSERT INTO users(username, password, email) VALUES ('{$username}', '{$password}', '{$email}')";
            $result = mysqli_obj_query(mysqli_new(), $sql);
            if ($result) {
                echo "<script>alert('注册成功!'); history.go(-1);</script>";
            } else {
                echo "<script>alert(''注册失败!'); history.go(-1);</script>";
            }
        }
    }
} else {
    echo "<script>alert('提交未成功!'); history.go(-1);</script>";
}
Example #3
0
<?php

require_once "../db/conn.php";
$mysqli = mysqli_new();
$sql = "SELECT * FROM `uploadStatus` WHERE time = (SELECT max( time ) FROM `uploadStatus` )";
$result = mysqli_obj_query($mysqli, $sql);
if (is_null($result) || 1 != $result->num_rows) {
    $ret = "query failed";
} else {
    while ($row = mysqli_fetch_assoc($result)) {
        echo json_encode($row);
    }
}
echo $ret;