123456789101112131415161718192021222324252627282930313233 |
- <?php
- require_once "sql.php";
- require_once "utils.php";
-
- function hash_password($password)
- {
- return md5($password);
- }
-
- function user_create()
- {
- $username = get_post("username");
- $password = get_post("password");
- if (strlen($username) < 3)
- error(422, "Username too short");
- if (database_exec("SELECT id FROM users WHERE `username` = :username",
- array(":username" => $username))->fetch() !== false)
- error(409, "Username already exists");
- database_exec("INSERT INTO users (`username`, `password`) ".
- "VALUES(:username, :password)", array(":username" => $username,
- ":password" => hash_password($password)));
- user_login($username);
- }
-
- function user_login($username = false )
- {
- if ($username === false)
- {
- $username = get_post("username");
- $password = get_post("password");
- }
- }
- ?>
|