|
PHP复制代码 <?php if ( ! defined('BASEPATH')) 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','用户名','callback_username_check|min_length[5]|max_length[10]');
$this->form_validation->set_rules('password','密码','required|matches[repassword]');
$this->form_validation->set_rules('repassword','确认密码','required');
$this->form_validation->set_rules('email','邮件','required|valid_email');
if($this->form_validation->run()==FALSE)
{
$this->load->view('myheader');
/*$this->load->helper('form');
echo form_open('');*/
$this->load->view('myform');
$this->load->view('myfooter');
}
else
{
$this->load->view('formsuccess');
}
}
public function username_check ($str)
{
if($str=='aaaaa')//检查输入的用户名是否存在
{
$this->form_validation->message('username_check','%s用户名已存在!');
}
else
{
return TRUE;
}
}
} 复制代码
正确输入后怎么不能跳转到formsuccess.php页面(要么无法显示,要么正在连接...) |
|