• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a model for the login

I am trying to learn codeigniter. I followed the Form Validation Example (https://codeigniter.com/userguide3/libra...ation.html).

I have manage to make it work but I would like to ask how would I include a model to validate the username and password in the DB and get the details.


you can use like this example in Model file.

PHP Code:
public function login($table,$email,$pass)
$query=$this->db->get();  // verileri getir

and u must change to application/config/autoload.php
$autoload['libraries'] = array('session','database'); 
like that. and make a sure true Config/database.php connect is right
and you must create controller like this
PHP Code:
public function login()
$result$this->Database_Model->login("Admin",$email,$pass); //1. Db in
                   $sess_array = array(
'id' => $result[0]->Id,
                       'email' => $result[0]->email,
                       'pass' => $result[0]->pass,


i think its gonna be help to u.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.