Added function to register new user

This commit is contained in:
2017-09-06 13:39:10 +07:00
parent 1ee4ca3730
commit ff67e487ce
4 changed files with 92 additions and 33 deletions

View File

@@ -12,8 +12,9 @@ class Access extends \Core\Model
'username varchar(25) NOT NULL',
'password char(13) NOT NULL',
'salt char(23) NOT NULL',
'name varchar(50) NOT NULL',
'full_name varchar(50) NOT NULL',
'registered_at date NOT NULL DEFAULT CURRENT_TIMESTAMP',
'privilage int(3) NOT NULL DEFAULT 0',
'status tinyint NOT NULL DEFAULT 0',
'PRIMARY KEY (id)'
]
@@ -42,7 +43,7 @@ class Access extends \Core\Model
try {
$db = static::connectDB();
$sql = "SELECT id, username, name, registered_at FROM user WHERE id = ?";
$sql = "SELECT id, username, full_name, registered_at FROM user WHERE id = ?";
$query = $db->prepare($sql);
@@ -61,7 +62,7 @@ class Access extends \Core\Model
public function login($args = [])
{
try {
$username = $args['username'];
$username = htmlspecialchars($args['username']);
$password = $args['password'];
$db = static::connectDB();
@@ -84,7 +85,7 @@ class Access extends \Core\Model
\Core\Session::put('userid', $user['id']);
\Core\Session::put('username', $user['username']);
\Core\Session::put('name', $user['name']);
\Core\Session::put('name', $user['full_name']);
$user_now = $user['username'];