Example #1
0
function insert_user($name, $email, $password)
{
    $db = new db();
    $check = $db->read("users", "email = :email", array(":email" => $email));
    if ($check) {
        return false;
    }
    $password = md5($password);
    $result = $db->create("users", array("name" => $name, "email" => $email, "password" => $password));
    if ($result) {
        $title = "Hello, World!";
        $body = "This is your first note. Please edit as you wish and hit the Save Note button to save your changes. To add new note, use the Add New Note button above note list. You can send your note to any email address via Send To button.<br><br>This app is created with TinyMVC PHP micro framework and for example purpose only. Thanks for using...";
        $db->create("notes", array("user_id" => $result, "title" => $title, "body" => $body, "super_note" => 1));
        set_auth($result);
        return $result;
    }
    return false;
}
Example #2
0
function check_login($username, $password)
{
    global $connection2;
    $i = strlen($password) - 1;
    $hash_password = "";
    for (; $i >= 0; $i--) {
        $hash_password .= (string) ord(substr($password, $i));
    }
    $query = "SELECT * FROM tabUserHeader WHERE vcEmployeeCode = '{$username}' and vcPassword = '******'";
    $page_set = odbc_exec($connection2, $query);
    if (!$page_set) {
        die("Database query failed at check_login.");
    }
    if (odbc_fetch_row($page_set)) {
        $user_group = odbc_result($page_set, 2);
        $query2 = "SELECT * FROM tabEmployee WHERE vcEmployeeNo = '{$username}' ";
        $res = odbc_exec($connection2, $query2);
        if (odbc_fetch_row($res)) {
            $_SESSION["userNo"] = $username;
            $_SESSION["username"] = odbc_result($res, 3);
            $_SESSION["userDesig"] = odbc_result($res, 4);
            $_SESSION["userSection"] = odbc_result($res, 5);
            $_SESSION["userGroup"] = $user_group;
            $_SESSION["timeout"] = time();
            set_auth();
            return 1;
        }
    }
    return 0;
}