Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: PHP  |  size: 1.05 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class User_model  extends CI_Model  {
  4.    
  5.         function __construct()
  6.     {
  7.         parent::__construct();
  8.     }
  9.         function allUsers($per_pg,$offset)
  10.         {
  11.             $query = $this->db->get('users',$per_pg,$offset);
  12.                   return $query->result_array();
  13.         }
  14.        
  15.         function usersCount()
  16.         {
  17.              return $this->db->count_all('users');
  18.         }
  19.         function insertuser()
  20.         {
  21.                 $name = $this->input->post('name');
  22.                 $data = array(
  23.                             'name' => $this->input->post('name'),
  24.                                 'email' => $this->input->post('email'),
  25.                                 'address' => $this->input->post('address'),
  26.                                 'postcode' => $this->input->post('postcode'),
  27.                                 'phone' => $this->input->post('phone'),
  28.                                 'username' => $this->input->post('username'),
  29.                                 'password' => md5($this->input->post('password'))
  30.                                
  31.                 );
  32.                 $this->db->insert('users', $data);
  33.                 $data['success'] = $this->session->set_flashdata('success', 'The user <strong>'.$name.'</strong> has been successfully inserted.');
  34.                
  35.                 redirect ('admin/dashboard', $data);
  36.         }