Advertisement
Guest User

Untitled

a guest
Jun 6th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. class UserModel extends CI_Model {
  3.  
  4. public function login($user,$pass) {
  5.  
  6. $query = $this->db->select('*')->from('tbl_user')
  7. ->where( array (
  8. 'usr_username' => $user,
  9. 'usr_password'=>$pass))
  10. ->count_all_results();
  11. return $query;
  12. }
  13. }
  14. ?>
  15.  
  16.  
  17.  
  18.  
  19. --------------------------------
  20.  
  21.  
  22.  
  23. <?php
  24. defined('BASEPATH') OR exit('No direct script access allowed');
  25.  
  26. class Ajax extends CI_Controller {
  27.  
  28. public function checklogin() {
  29. $username = $this->input->post('username');
  30. $password = $this->input->post('password');
  31.  
  32. $result = $this->UserModel->login($username,$password);
  33. if($result > 0) {
  34. $arr = array('success'=>true,'data'=>$username);
  35. echo json_encode($arr);
  36. } else {
  37. $arr = array('success'=>false,'data'=>'Username or password is incorrect.');
  38. echo json_encode($arr);
  39. }
  40.  
  41. }
  42.  
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement