我有自動加載輔助形式和autoload.php庫形式驗證無法獲得form_validation-> set_rules和form_validation-> set_message錯誤
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller {
var $data;
public function __construct(){
parent::__construct();
$this->data=array('page'=>'login_view','title'=>'login');
$this->load->model("Login_model");
}
public function index()
{
//get the posted values
$data=$this->data;
$this->load->view('template',$data);
}
public function checklogin(){
//form validation
$data=$this->data;
$this->form_validation->set_rules('username','Username','required');
$this->form_validation->set_rules('password' ,'Password','required|callback_verifyUser');
if($this->form_validation->run()==false){
$this->load->view('template',$data);
}
else{
}
}
public function verifyUser(){
$name=$this->input->post('username');
$pass=$this->input->post('password');
$option=$this->input->post('optionlist');
if($this->Login_model->login($name,$pass,$option)){
return true;
}else{
//user doesn't exist
//echo "Wrong username and password";
$this->form_validation->set_message('verifyUser','Incorrect officer_id or password. Please try again');
return false;
}
}
}
?>
是doen't顯示任何錯誤信息,用戶名是問題當我留下空白時,需要或密碼是必需的。它簡單地重新登錄到LOGIN_VIEW.PHP,而不顯示任何錯誤消息,即用戶名是空白的
該文檔所謂的形式驗證用於顯示錯誤。
的觀點login_view.php可以看出U形式在這裏http://pastebin.com/T2zMYGn1
嗯......一切看起來OK我。你有什麼機會向我們展示template.php視圖文件? – Craig
yeh sure template.php http://pastebin.com/850jTAc5 –
你可以看看完整的代碼,如果你希望https://github.com/rachidasen/nic/tree/learnigniter –