即使在多次访问文档后,我在理解控制器的使用方面也存在差距。我有以下内容:
class Membership extends CI_Controller
{
/*Load the login view first assuming user is member*/
public function index()
{
$this->load->view('login');
}
/*if not member, load register view*/
public function register()
{
$this->load->view('register');
}
/*view to recover user credentials*/
public function recover()
{
$this->load->view('recover');
}
public function enroll_user()
{
/*Retrieve post parameters*/
$fullname = $this->input->post('fullname');
$email = $this->input->post('email');
$mobile = $this->input->post('mobile');
$home = $this->input->post('home');
$username = $this->input->post('username');
$password = $this->input->post('password');
$confirmPassword = $this->input->post('cpassword');
}
}
现在示例当用户单击主页上的立即注册链接时, register() 函数应该加载视图。但是在他填写完表格并提交之后,我应该提交到哪个函数呢?这是否意味着我必须为每个功能创建两个函数,一个用于加载视图(register.php),第二个用于处理该函数的操作(enroll_user)?