我是codeIgniter和PHP的新手,我有一个问题,我无法在线找到解决方案。我有一个注册表单,当重定向到控制器我的帖子数据没有设置,我做了一个测试,看看它是否设置,它失败,更令人讨厌的是我的登录表单按预期工作,代码是相同的。我的观点是:
$attributes = array(
'id' => 'formID',
'class' => 'formClass'
);
echo form_open('user/register_validation/', $attributes);
echo validation_errors();
echo "<p>Username: ";
echo form_input('rusername');
echo "</p>";
echo "<p>Email: ";
echo form_input('remail', $this->input->post('remail'));
echo "</p>";
echo "<p>Password: ";
echo form_input('rpassword');
echo "</p>";
echo "<p>Confirm Password: ";
echo form_input('cpassword');
echo "</p>";
echo "<p>";
echo form_submit('register_submit', 'Register');
echo "</p>";
echo form_close();
?>
控制器方法:
public function register_validation(){
$this->load->library('form_validation');
$this->form_validation->set_rules('remail', 'Remail', 'required|trim|valid_email|is_unique[userbee_db_table.email_user]');
$this->form_validation->set_rules('rpassword', 'Rpassword', 'required|trim');
$this->form_validation->set_rules('cpassword', 'Cpassword', 'required|trim|matches[rpassword]');
$this->form_validation->set_message('is_unique', 'That email address already exists.');
if ($this->form_validation->run()){
redirect('user/register_user');
}else{
$this->load->view('register_view');
}
}
我的控制器没有构造函数,我正在使用WAMP3虚拟服务器。我知道控制器方法重定向到另一个方法但是加载模型并插入用户,但是没有数据从表单传递到第一个控制器方法,请帮忙!