[eluser]Fahad Alrahbi[/eluser]
hello , i have pro when i use return inside model function
Model
Code:
function dogloin($u,$p){
$query = $this->db->get_where('adm', array('username' => $u,'password'=>$p));
if($query->num_rows()==1){
return true;
}else{
return false;
}
}
AND controller
Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
All Copyrights reserved.
Programmer information
Name : Fahad Salim Alrahbi
Location: Sultanate of Oman - Muscat
Email : [email protected]
Tel : +968 98985262
*/
class login extends CI_Controller{
public function __construct()
{
parent::__construct();
//Instantiate a Doctrine Entity Manager
// $this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
}
function index(){
#$this->parser->assign('center_tpl','login');
$this->parser->parse('login.tpl');
}
#this is my controller
function dologin(){
$this->parser->assign('error', '');
$this->parser->assign('message', '');
if($this->input->post('doform') == 'go' ){
// Set the validation rules if this is a submit
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[2]|max_length[12]|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
if ( ! $this->form_validation->run() )
{
$data['error'] = 'Check and fix the form errors below';
}
else
{
$ci = &get;_instance();
$this->load->model('Login_model');
#$this->Login_model->dogloin('adm','123123');
$this->Login_model->dogloin('adm','123123');
#$data['message'] = 'Thanks for posting!';
}
// These assignments are passed by the associative array
$data['title'] = 'Welcome to the Smarty Website';
$data['bold'] = true;
$data['ip_address'] = $this->input->server('REMOTE_ADDR');
$this->parser->parse( 'login.tpl', $data );
}else{
$this->parser->parse( 'login.tpl');
}
}
}
?>
Error
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Login_model::$form_validation
Filename: plugins/function.ci_form_validation.php
Line Number: 47
Fatal error: Call to a member function error() on a non-object in C:\xampp\htdocs\cic\application\third_party\Smarty\plugins\function.ci_form_validation.php on line 57
if i remove return it will work !!