CI中表单提交的问题
function index(){
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('file');
}
else
{
$this->load->view('formsuccess');
}
}这里的$this->form_validation->set_rules是什么意思啊?不懂,还有后面跟的属性都是什么意思?请高手给详细解释下,谢谢!!
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
还有这两句,是什么意思? 本帖最后由 qi_ruo 于 2011-11-26 13:28 编辑
http://codeigniter.org.cn/user_guide/libraries/loader.html
http://codeigniter.org.cn/user_guide/libraries/form_validation.html
手册上很详细的
有刷分嫌疑 likely_01 发表于 2011-11-29 13:15 static/image/common/back.gif
有刷分嫌疑
我刚刚接触CI,还在摸索中,请手下留情,不要随意重伤他人。 $this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
呵呵 这个手册上的确是有,$this->load->helper(array('form', 'url'));这个是载入辅助函数,下次用得时候可以直接调用form,url的方法了,$this->load->library('form_validation');这个是自动装载表单验证的类库,也就是说调用了这个函数,在表单提交之前就会验证你的格式是否正确,必填项是否填写等
页:
[1]