Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. A PHP Error was encountered
  2.  
  3. Severity: Notice
  4.  
  5. Message: Undefined variable: password
  6.  
  7. Filename: controllers/users.php
  8.  
  9. Line Number: 71
  10.  
  11. Backtrace:
  12.  
  13. File: C:xampphtdocsciapplicationcontrollersusers.php
  14. Line: 71
  15. Function: _error_handler
  16.  
  17. File: C:xampphtdocsciindex.php
  18. Line: 315
  19. Function: require_once
  20.  
  21.  
  22. Fatal error: Call to undefined method CI_DB_mysqli_driver::ger() in C:xampphtdocsciapplicationmodelsuser_model.php on line 40
  23. A PHP Error was encountered
  24.  
  25. Severity: Error
  26.  
  27. Message: Call to undefined method CI_DB_mysqli_driver::ger()
  28.  
  29. Filename: models/user_model.php
  30.  
  31. Line Number: 40
  32.  
  33. Backtrace:
  34.  
  35. <?php
  36.  
  37. class Users extends CI_Controller {
  38. function __construct(){
  39. parent::__construct();
  40. $this->load->model('user_model');
  41. }
  42. // public function show($user_id){
  43.  
  44. // //$this->load->model('User_model');
  45.  
  46. // $data['results'] = $this->user_model->get_users($user_id);
  47. // //$data['welcome'] = "Bienvenido a la web";
  48. // // $data['result'] = $result;
  49. // $this->load->view('user_view',$data);
  50. // }
  51.  
  52. // public function insert()
  53. // {
  54.  
  55. // $username = "peter";
  56. // $password = "secret";
  57.  
  58. // $this->user_model->create_users([
  59. // 'username' => $username,
  60. // 'password' => $password
  61.  
  62. // ]);
  63. // }
  64.  
  65. // public function update()
  66. // {
  67. // $id = 3;
  68. // $username = "william";
  69. // $password = "nosecret";
  70.  
  71. // $this->user_model->update_users([
  72. // 'username' => $username,
  73. // 'password' => $password
  74.  
  75. // ],$id);
  76. // }
  77. // public function delete()
  78. // {
  79. // $id = 4;
  80.  
  81. // $this->user_model->delete_users($id);
  82.  
  83.  
  84. // }
  85. public function login(){
  86.  
  87. $this->form_validation->set_rules('username','Username','trim|required|min_length[3]');
  88. $this->form_validation->set_rules('password','Password','trim|required|min_length[3]');
  89. $this->form_validation->set_rules('confirm_password','Confirm Password','trim|required|min_length[3]|matches[password]');
  90. if($this->form_validation->run() == FALSE){
  91. $data = array(
  92.  
  93. 'errors' => validation_errors()
  94.  
  95. );
  96.  
  97. $this->session->set_flashdata($data);
  98.  
  99. redirect('home');
  100. } else {
  101.  
  102. $username = $this->input->post('username');
  103. $pasword = $this->input->post('password');
  104.  
  105. $user_id = $this->user_model->login_user($username, $password);
  106.  
  107.  
  108. if ($user_id){
  109. $userdata = array(
  110. 'user_id' => $user_id,
  111. 'username' => $username,
  112. 'logged_in' => true
  113.  
  114. );
  115.  
  116.  
  117. $this->seession->set_userdata($userdata);
  118. $this->seession->set_flashdata('login_sucess','estas logueado');
  119.  
  120. redirect('home/index');
  121.  
  122.  
  123. } else {
  124. $this->seession->set_flashdata('login_fail','NO estas logueado');
  125. redirect('home/index');
  126. }
  127.  
  128. }
  129.  
  130.  
  131.  
  132.  
  133. /*echo $this->input->post('username');*/
  134.  
  135. }
  136.  
  137. }
  138.  
  139. ?>
  140.  
  141. <?php
  142.  
  143. class User_model extends CI_Model{
  144.  
  145. // public function get_users($user_id){
  146.  
  147. // $this->db->where(['id' => $user_id]);
  148. // $query = $this->db->get('users');
  149.  
  150.  
  151. // return $query->result();
  152.  
  153. // //$query = $this->db->query("SELECT * FROM users");
  154.  
  155.  
  156. // }
  157.  
  158.  
  159. // public function create_users($datos){
  160.  
  161. // $this->db->insert('users',$datos);
  162. // }
  163. // public function update_users($datos,$id){
  164. // $this->db->where(['id'=>$id]);
  165. // $this->db->update('users',$datos);
  166. // }
  167.  
  168. // public function delete_users($id){
  169. // $this->db->where(['id'=>$id]);
  170. // $this->db->delete('users');
  171. // }
  172.  
  173.  
  174.  
  175. public function login_user($username,$password) {
  176.  
  177. $this->db->where('username', $username);
  178. $this->db->where('password', $password);
  179.  
  180. $result = $this->db->ger('users');
  181.  
  182. if ($result->num_rows() ==1){
  183. return $result->row(0)->id;
  184.  
  185. }else {
  186. return false;
  187. }
  188.  
  189. }
  190.  
  191. }
  192.  
  193. ?>
  194.  
  195. $pasword = $this->input->post('password');
  196.  
  197. $user_id = $this->user_model->login_user($username, $password);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement