]>
jfr.im git - z_archive/KronOS.git/blob - core/login.php
55203371bb43bc45f84b559530c8d27c8fe40e2d
4 if (empty($_POST['user']) || empty($_POST['pass'])) {
5 make_reply('Username or password empty.', 1);
7 $sth = $db->prepare('SELECT uid FROM users WHERE username = ? AND password = ?');
8 $sth->bind_param('ss', $_POST['user'], sha1(PWSALT
.$_POST['pass']));
10 $sth->bind_result($uid);
11 if (!$sth->fetch()) { // no row returned
12 make_reply('Username or password incorrect.', 2);
15 // row returned, user/pw good
17 $sth = $db->prepare('INSERT INTO sessions(sid, uid, started, last, active) VALUES (NULL, ?, NOW(), NOW(), 1)');
18 $sth->bind_param('i', $uid);
20 $sid = $sth->insert_id
;
22 make_reply(array('uid' => $uid, 'sid' => $sid));