mourne_rcpp_fw/Mourne-CI/application/models/user_model.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2021-10-30 19:02:07 +02:00
<?php
class User_model extends MO_Model
{
public function __construct()
2021-10-30 19:02:07 +02:00
{
parent::__construct();
2021-10-30 19:02:07 +02:00
}
public function login_check($data)
2021-10-30 19:02:07 +02:00
{
$sql = "SELECT passkey FROM users WHERE username=" . $this->db->escape($data['username']);
2021-10-30 19:02:07 +02:00
$q = $this->db->query($sql);
2021-10-30 19:02:07 +02:00
if ($q->num_rows > 0) {
$row = $q->row_array();
2021-10-30 19:02:07 +02:00
if ($row['passkey'] == $data['password']) {
return true;
} else {
return false;
}
} else {
return false;
}
}
2021-10-30 19:02:07 +02:00
public function get_userid($username)
2021-10-30 19:02:07 +02:00
{
$sql = "SELECT id FROM users WHERE username=" . $this->db->escape($username);
$q = $this->db->query($sql);
$res = $q->row_array();
return $res['id'];
2021-10-30 19:02:07 +02:00
}
public function reg_username_check($uname)
2021-10-30 19:02:07 +02:00
{
$sql = "SELECT username FROM users WHERE username=" . $this->db->escape($uname);
$q = $this->db->query($sql);
if ($q->num_rows() == 0) {
return true;
} else {
return false;
}
2021-10-30 19:02:07 +02:00
}
public function reg_write($data)
{
$sql = "INSERT INTO users VALUES(default, "
. $this->db->escape($data['username']) . ", '"
. $data['password'] . "', '"
2021-10-30 19:02:07 +02:00
. $data['email'] . "',
default, default, default)";
return $this->db->query($sql);
}
2021-10-30 19:02:07 +02:00
}
//nowhitesp