点击验证电子邮件,在codeigniter

时间:2016-10-28 07:49:47

标签: php codeigniter email

一旦提交表格,发送带有验证链接的电子邮件,用户点击该链接就会收到500内部服务器错误。一旦我点击链接状态,就会从0更改为1并需要设置链接的时间限制 错误:

500 - 内部服务器错误。 您正在查找的资源存在问题,无法显示。

以下是我的电子邮件验证代码。

注册:

function signup()
{
    $this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<br /><span class="error"> ','</span>');
    $this->form_validation->set_rules('email','Email','required|is_unique[profile_details.email]');

    if($this->form_validation->run()== FALSE)   
   {    
    $data['country'] = $this->signup_model->getcountry();  
    $data['mainpage']='signup';
    $this->load->view('templates/template',$data);
    }
else
    {
        $data=array(            

      'email'=>$this->input->post('email'),

       );

       if($this->signup_model->insertprofiledetails($data))
           {
                if ($this->signup_model->sendEmail($this->input->post('email')))
                {
                    redirect("index.php/welcome/add");
                }
                else
                {
                    redirect("index.php/welcome/add");
                }
            }
            else
            {
                redirect('index.php/welcome/add');
            }
        }
    }

function verify($hash=NULL)
{
    if ($this->signup_model->verifyEmailID($hash))
    {
        $this->session->set_flashdata('verify_msg','<div class="alert alert-success text-center">Your Email Address is successfully verified! Please login to access your account!</div>');
        redirect('index.php/welcome/add');
    }
    else
    {
        $this->session->set_flashdata('verify_msg','<div class="alert alert-danger text-center">Sorry! There is error verifying your Email Address!</div>');
        redirect('index.php/welcome/add');
    }
}

型号:

function sendEmail($to_email)
{

    //configure email settings
    $config=Array(
    'protocol'=> 'smtp',
    'smtp_host' => 'ssl://smtp.gmail.com', //smtp host name
    'smtp_port' => '465', //smtp port number
    'smtp_user' => 'xxxx@gmail.com',
    'smtp_pass' => 'yyyyy', //$from_email password
    'mailtype' =>'html',
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE
    );

    //send mail
    $this->load->library('email',$config);
    $this->email->from('xxxx@gmail.com', 'Admin');
    $this->email->to('yyyyy@gmail.com');
    $this->email->subject('Email Verification');
    $this->email->message('Dear User,<br /><br />Please click on the below activation link to verify your email address.<br /><br /> http://qa.domain.in/index.php/welcome/verify/' . md5($to_email) . '<br /><br /><br />Thanks<br />Mydomain Team');
    $this->email->set_newline("\r\n");
    if($this->email->send())
    { 
     redirect('welcome/add');
    } else { echo $this->email->print_debugger(); }
}

function verifyEmailID($key)
{
    $data = array('status' => 1);
    $this->db->where('md5(email)', $key);
    return $this->db->update('profile_details', $data);
}

1 个答案:

答案 0 :(得分:0)

检查是否缺少signup_model类或sign_up模型类本身或控制器中任何方法的任何右括号