Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A PHP Error was encountered
- Severity: Notice
- Message: Undefined variable: password
- Filename: controllers/users.php
- Line Number: 71
- Backtrace:
- File: C:xampphtdocsciapplicationcontrollersusers.php
- Line: 71
- Function: _error_handler
- File: C:xampphtdocsciindex.php
- Line: 315
- Function: require_once
- Fatal error: Call to undefined method CI_DB_mysqli_driver::ger() in C:xampphtdocsciapplicationmodelsuser_model.php on line 40
- A PHP Error was encountered
- Severity: Error
- Message: Call to undefined method CI_DB_mysqli_driver::ger()
- Filename: models/user_model.php
- Line Number: 40
- Backtrace:
- <?php
- class Users extends CI_Controller {
- function __construct(){
- parent::__construct();
- $this->load->model('user_model');
- }
- // public function show($user_id){
- // //$this->load->model('User_model');
- // $data['results'] = $this->user_model->get_users($user_id);
- // //$data['welcome'] = "Bienvenido a la web";
- // // $data['result'] = $result;
- // $this->load->view('user_view',$data);
- // }
- // public function insert()
- // {
- // $username = "peter";
- // $password = "secret";
- // $this->user_model->create_users([
- // 'username' => $username,
- // 'password' => $password
- // ]);
- // }
- // public function update()
- // {
- // $id = 3;
- // $username = "william";
- // $password = "nosecret";
- // $this->user_model->update_users([
- // 'username' => $username,
- // 'password' => $password
- // ],$id);
- // }
- // public function delete()
- // {
- // $id = 4;
- // $this->user_model->delete_users($id);
- // }
- public function login(){
- $this->form_validation->set_rules('username','Username','trim|required|min_length[3]');
- $this->form_validation->set_rules('password','Password','trim|required|min_length[3]');
- $this->form_validation->set_rules('confirm_password','Confirm Password','trim|required|min_length[3]|matches[password]');
- if($this->form_validation->run() == FALSE){
- $data = array(
- 'errors' => validation_errors()
- );
- $this->session->set_flashdata($data);
- redirect('home');
- } else {
- $username = $this->input->post('username');
- $pasword = $this->input->post('password');
- $user_id = $this->user_model->login_user($username, $password);
- if ($user_id){
- $userdata = array(
- 'user_id' => $user_id,
- 'username' => $username,
- 'logged_in' => true
- );
- $this->seession->set_userdata($userdata);
- $this->seession->set_flashdata('login_sucess','estas logueado');
- redirect('home/index');
- } else {
- $this->seession->set_flashdata('login_fail','NO estas logueado');
- redirect('home/index');
- }
- }
- /*echo $this->input->post('username');*/
- }
- }
- ?>
- <?php
- class User_model extends CI_Model{
- // public function get_users($user_id){
- // $this->db->where(['id' => $user_id]);
- // $query = $this->db->get('users');
- // return $query->result();
- // //$query = $this->db->query("SELECT * FROM users");
- // }
- // public function create_users($datos){
- // $this->db->insert('users',$datos);
- // }
- // public function update_users($datos,$id){
- // $this->db->where(['id'=>$id]);
- // $this->db->update('users',$datos);
- // }
- // public function delete_users($id){
- // $this->db->where(['id'=>$id]);
- // $this->db->delete('users');
- // }
- public function login_user($username,$password) {
- $this->db->where('username', $username);
- $this->db->where('password', $password);
- $result = $this->db->ger('users');
- if ($result->num_rows() ==1){
- return $result->row(0)->id;
- }else {
- return false;
- }
- }
- }
- ?>
- $pasword = $this->input->post('password');
- $user_id = $this->user_model->login_user($username, $password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement