如何使用控制器中的值设置链路


How to set a link using the values from controller

我有一个链接放置在我的视图页面使用codeigniter

   <a href='".base_url()."user/pass_confirmation/$encrypted_string/$email'>

但是来自控制器的电子邮件和encrypted_string .

这不是我的视图

控制器

 function email_check()
{
    $email=$this->input->post('email');
    echo $email;
     $data = array(
        'user_email' =>$email, 
        );
   $result = $this->UM->email_verify($data);
   if($result)
   {
       echo $result;
       $date   = date(Y-m-d);
       $string = $email."-".$date;
       $encrypted_string = md5($string);
       echo $encrypted_string;
       $res=$this->UM->insert_key($encrypted_string,$result);
        redirect(base_url()."user/forgot_pass");
   }
 }

我能做什么?

您需要从uri段中获取它,如:

$string = $this->uri->segment(3); 
$email = $this->uri->segment(4); 

在route.php文件中这样写:

$route['controllerclass/function/(:any)/(:any)'] = "pass_confirmation/$1/$2";

,你的链接将是

domain.com/pass_confirmation/someval/someval

然后你可以使用像

这样的段来获取字符串和电子邮件
$val1 = $this->uri->segment(3); 
$val2 = $this->uri->segment(4);