幽默好难学
2017-11-27 14:25求各位帮忙看看哪里出问题了?
控制器代码如下:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Form extends CI_Controller{
public function index(){
$this->load->helper(array('form','url'));
$this->load->library('form_validation');//验证初始化函数
$this->form_validation->set_rules('username', 'Username', arrary($this->users_model, 'valid_username'));
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
//级联规则
if ($this->form_validation->run()==FALSE)
{
$this->load->view('test/myform');
}
else{
$this->load->view('test/formsuccess');
}
}
public function username_check($str)
{
if($str=='test'){
$this->form_validation->set_message('username_check', 'The {field} field can not be the word "test"');
return FALSE;
}
else{
return TRUE;
}
}
}
视图代码如下:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Form extends CI_Controller{
public function index(){
$this->load->helper(array('form','url'));
$this->load->library('form_validation');//验证初始化函数
$this->form_validation->set_rules('username', 'Username', arrary($this->users_model, 'valid_username'));
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
//级联规则
if ($this->form_validation->run()==FALSE)
{
$this->load->view('test/myform');
}
else{
$this->load->view('test/formsuccess');
}
}
public function username_check($str)
{
if($str=='test'){
$this->form_validation->set_message('username_check', 'The {field} field can not be the word "test"');
return FALSE;
}
else{
return TRUE;
}
}
}
另一个页面:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Form extends CI_Controller{
public function index(){
$this->load->helper(array('form','url'));
$this->load->library('form_validation');//验证初始化函数
$this->form_validation->set_rules('username', 'Username', arrary($this->users_model, 'valid_username'));
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]');
//级联规则
if ($this->form_validation->run()==FALSE)
{
$this->load->view('test/myform');
}
else{
$this->load->view('test/formsuccess');
}
}
public function username_check($str)
{
if($str=='test'){
$this->form_validation->set_message('username_check', 'The {field} field can not be the word "test"');
return FALSE;
}
else{
return TRUE;
}
}
}
但是不能显示效果,显示页面不存在。
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 各位大佬帮忙看看这段求标准化和标准方差哪里出问题了?
- c语言
- c++
- 1个回答
- 请各位大神帮忙看一下这个题目
- java
- 1个回答
- java程序中ArrayListReverseIterator,打印不出来,请各位帮忙看看
- java
- 1个回答
- tomcat 404 提示连接不上mysql数据库????? 求各位大神帮忙,拜托
- 数据库
- 服务器
- mysql
- tomcat
- 2个回答
- 麻烦各位大神帮忙看看C# sql
- 数据库
- c#
- 2个回答
换一换