我正在尝试在注册帐户后实施电子邮件验证 . 因此,在注册帐户后,将向用户电子邮件发送一封电子邮件进行验证 . 电子邮件是使用codeigniter的电子邮件类发送的 .
发送电子邮件的代码如下
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from('admin@mathplication.com', 'admin');
$this->email->to($user_email);
$this->email->subject('Registration verification for mathplication');
$this->email->message('
Thanks for signing up!
Your account has been created, you can login with the following credentials
after you have activated your account by pressing the url below.
Please click this link to activate your account:
<a href='.base_url('verify').'?email='.$user_email.'&rand='.$user_rand.'>Click Here</a>');
$this->email->send();
并在config文件夹中的routes.php中
$route['verify'] = "login_register/view_verify
其中view_verify是我的login_register控制器中的函数
在这个view_verify里面,我将检查我传递的两个参数,即电子邮件和生成的随机字符串 .
function view_verify($email,$rand)
{
//$email = $this->input->get('email');
//$rand = $this->input->get('rand');
$this->load->database();
$this->load->model('login_model');
$result= $this->login_model->email_verification($email,$rand);
if($result==TRUE)
{
$this->load->view('pages/verify');
}
}
我将找到404页面找不到错误 . 我不确定我的变量路由是否存在问题,或者是否存在通过url将参数传递给控制器的另一种方法 . 在此先感谢您的帮助 .
2 回答
如果您要在URL中使用查询字符串,则需要在配置中启用它 . 由于电子邮件地址,
permitted_uri_chars
可能还存在问题 .您可以使用用户ID和nonce生成url,如:
哪个应该产生类似的东西
然后在路线:
此时,函数
view_verify
应该与现在一样正常工作,除非您需要调整模型以通过用户ID而不是通过电子邮件进行查找 .