google_forms/application/models/User_model.php

49 lines
1.2 KiB
PHP
Raw Normal View History

2024-07-11 12:05:44 +00:00
<?php
2024-08-09 12:04:48 +00:00
class User_model extends CI_Model
{
public function register($enc_password)
{
$data = array(
'email' => $this->input->post('email'),
'username' => $this->input->post('username'),
'password' => $enc_password
);
return $this->db->insert('users', $data);
2024-07-11 12:05:44 +00:00
}
2024-08-09 12:04:48 +00:00
public function login($username, $password)
{
$this->db->where('username', $username);
$this->db->where('password', $password);
$result = $this->db->get('users');
if ($result->num_rows() == 1) {
return $result->row(0)->id;
} else {
return false;
}
2024-07-11 12:05:44 +00:00
}
2024-08-09 12:04:48 +00:00
public function check_username_exists($username)
{
$query = $this->db->get_where('users', array('username' => $username));
if (empty($query->row_array())) {
return true;
} else {
return false;
}
2024-07-11 12:05:44 +00:00
}
2024-08-09 12:04:48 +00:00
public function check_email_exists($email)
{
$query = $this->db->get_where('users', array('email' => $email));
if (empty($query->row_array())) {
return true;
} else {
return false;
}
2024-07-11 12:05:44 +00:00
}
}