如何根据codeigniter中的单选按钮值发送邮件?

时间:2017-02-09 09:36:41

标签: javascript php jquery codeigniter email

我的应用程序中有一个选择表单。我有四个字段,一个是选择,评论,结果和两个选中和选中的单选按钮..

所以我想要做的是当人们点击所选单选按钮时我需要发送所选邮件..如果选中未选中单选按钮,则需要发送未选择邮件的邮件..

我的控制器代码:

public function requirement()
    {
        $this->load->model('RequirementModel');
        $data['user'] = $this->RequirementModel->getusers();
        $this->load->view('Requirements/requirements', $data);
        $insert = array(
            'role_name'             => $this->input->post('role_name'),
            'vacancies'             => $this->input->post('vacancies'),
            'experience'            => $this->input->post('experience'),
            'jd'                    => $this->input->post('jd'),
            'hiring_contact_name'   => $this->input->post('hiring_contact_name'),
            'hiring_contact_number' => $this->input->post('hiring_contact_number'),
            'user_id'               => implode(',', $this->input->post('user_id')),
        );
        $this->RequirementModel->add_requirement($insert);
        $all_users = $this->input->post('user_id');
        foreach ($all_users as $key) {
            $get_email             = $this->RequirementModel->get_user_email_by_id($key);
            $role_name             = $this->input->post('role_name');
            $vacancies             = $this->input->post('vacancies');
            $experience            = $this->input->post('experience');
            $jd                    = $this->input->post('jd');
            $hiring_contact_name   = $this->input->post('hiring_contact_name');
            $hiring_contact_number = $this->input->post('hiring_contact_number');
            $config                = array(
                'protocol'  => 'smtp',
                'smtp_host' => 'ssl://md-in-42.webhostbox.net',
                'smtp_port' => 465,
                'smtp_user' => 'test3@clozloop.com',
                'smtp_pass' => 'test3',
            );
            $this->load->library('email', $config);
            $this->email->set_mailtype("html");
            $this->email->from('test3@clozloop.com', 'bharathi');
            $this->email->to($get_email);
            $this->email->subject('this is our requirements pls go through it');
            $link = 'Click on this link - <a href="http://localhost/job_portal/index.php/Login/signin">Click Here</a>';
            $this->email->message($link);
            // $this->email->message("Dear,\n\nRole Name:$role_name, Vacancies:$vacancies,experience:$experience,jd:$jd,hiring_contact_number:$hiring_contact_number,hiring_contact_name:$hiring_contact_name.\n\nThanks, \nGlobaalign.");
            //$this->email->send();
            //print_r($get_email);
            if ($this->email->send()) {
                echo "email sent";
            } else {
                echo "email failed";
            }
        }

请帮我怎么做..

谢谢

1 个答案:

答案 0 :(得分:0)

以下是解决方案:

如果($数据[ 'selection_process'] == 1)

{

//发送所选邮件

}

否则

{

//发送未选择的邮件

}