Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UserModel extends CI_Model {
- public function login($user,$pass) {
- $query = $this->db->select('*')->from('tbl_user')
- ->where( array (
- 'usr_username' => $user,
- 'usr_password'=>$pass))
- ->count_all_results();
- return $query;
- }
- }
- ?>
- --------------------------------
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Ajax extends CI_Controller {
- public function checklogin() {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $result = $this->UserModel->login($username,$password);
- if($result > 0) {
- $arr = array('success'=>true,'data'=>$username);
- echo json_encode($arr);
- } else {
- $arr = array('success'=>false,'data'=>'Username or password is incorrect.');
- echo json_encode($arr);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement