Php 如何将注册表重定向到codeigniter上的另一页

Php 如何将注册表重定向到codeigniter上的另一页,php,forms,codeigniter,Php,Forms,Codeigniter,当用户提交注册表单时,我如何重定向到成功页面,问题是当我提交表单时,它将重定向到成功视图,但页面显示404未找到。我的代码有问题吗 公共职能注册(){ 用这个 redirect('controller/function'); 使用重定向() 请检查我的更改 $this->load->library('form_validation'); $this->form_validation->set_rules('fname','First Name','required'

当用户提交注册表单时,我如何重定向到成功页面,问题是当我提交表单时,它将重定向到成功视图,但页面显示404未找到。我的代码有问题吗

公共职能注册(){

用这个

 redirect('controller/function');
使用
重定向()


请检查我的更改

$this->load->library('form_validation');

$this->form_validation->set_rules('fname','First Name','required');
$this->form_validation->set_rules('lname','Last Name','required');
$this->form_validation->set_rules('username','username','required');
$this->form_validation->set_rules('password','Password','required');
$this->form_validation->set_rules('cpassword','Confim Password','required|matches[password]');

if ($this->form_validation->run()  ) {

    $this->load->model('Registration');

    $this->Registration->create(
        ['fname' => ucfirst($_POST['fname']),
         'lname' => ucfirst($_POST['lname']), 
         'username' => ucfirst($_POST['username']),
         'password' => md5($_POST['password'])]);   

    redirect(base_url().'templates/rsuccess', 'location', 301);


} else {
$view_data['page_title'] = 'Register first';
$view_data['errors'] = $this->form_validation->error_array();

$this->load->view('templates/header', $view_data);
$this->load->view('auth/registration');
$this->load->view('templates/footer');

}
}

重定向(base_url().“Controller/function”);请为您的代码段提供一些上下文。特别是,目前尚不清楚OP应如何将您的代码段添加到其代码中。请为您的代码段提供一些上下文。特别是,目前尚不清楚OP应如何将您的代码段添加到其代码中。
redirect(base_url().'Controller/function name');
$this->load->library('form_validation');

$this->form_validation->set_rules('fname','First Name','required');
$this->form_validation->set_rules('lname','Last Name','required');
$this->form_validation->set_rules('username','username','required');
$this->form_validation->set_rules('password','Password','required');
$this->form_validation->set_rules('cpassword','Confim Password','required|matches[password]');

if ($this->form_validation->run()  ) {

    $this->load->model('Registration');

    $this->Registration->create(
        ['fname' => ucfirst($_POST['fname']),
         'lname' => ucfirst($_POST['lname']), 
         'username' => ucfirst($_POST['username']),
         'password' => md5($_POST['password'])]);   

    redirect(base_url().'templates/rsuccess', 'location', 301);


} else {
$view_data['page_title'] = 'Register first';
$view_data['errors'] = $this->form_validation->error_array();

$this->load->view('templates/header', $view_data);
$this->load->view('auth/registration');
$this->load->view('templates/footer');

}
}