Welcome Guest, Not a member yet? Register   Sign In
How to handle checkboxes
#7

(This post was last modified: 11-24-2014, 02:57 PM by alexandervj.)

Sure, here is my controller fucntion

public function response_validation(){

$this->load->library('form_validation');
$this->form_validation->set_rules('subject', 'Subject', 'required');
$this->form_validation->set_rules('message', 'Message', 'required');
//$this->form_validation->set_rules('attachments', 'Attachments', 'required');
$this->form_validation->set_rules('use_email', 'Email', 'required');

if($this->form_validation->run()){

//load email library and model_users
$this->load->library('email', array('mailtype'=>'html'));
$this->load->model('model_users');

//build email message
$this->email->from('[email protected]', "Email");
//$this->email->from($this->input->post('use_email'), "Email");
$this->email->to($this->input->post('send_to'));
$this->email->subject($this->input->post('subject'));
$message = nl2br($this->input->post('message'));
$signature = nl2br($this->input->post('signature'));
$message = "<p>".$message."</p>";
$message .= "<p>".$signature."</p>";
$this->email->message($message);

// attachments

foreach($this->input->post('attachments') as $attachement){
if ($attachement == 'nui'){
$this->email->attach('http://www.site.com/wp-content/uploads/2014/07/image1.jpg'); //this is not the actual location of the files, just made up for privacy
}
if ($attachement == 'lidar'){
$this->email->attach('http://www.site.com/wp-content/uploads/2014/07/image2.jpg');
}
if ($attachement == 'optical'){
$this->email->attach('http://www.site.com/wp-content/uploads/2014/07/image3.jpg');
}
// etc.
}

if ($this->email->send()){
$this->load->view('response_sent');
} else {
echo "There was a problem. Please contact the Administrator.";
}

} else {
$this->load->view('main/request_details/$r->Submitted');
}

}




and heres my view...


<td>
<input type="checkbox" name="attachments[]" value="nui">NUI-IR Laser Array Chip<br>
<input type="checkbox" name="attachments[]" value="lidar">LiDAR - IR Laser Array Field<br>
<input type="checkbox" name="attachments[]" value="optical">Optical Solutions<br>
<input type="checkbox" name="attachments[]" value="none">None<br>
</td>
Reply


Messages In This Thread
How to handle checkboxes - by alexandervj - 11-24-2014, 02:02 PM
RE: How to handle checkboxes - by Rufnex - 11-24-2014, 02:23 PM
RE: How to handle checkboxes - by alexandervj - 11-24-2014, 02:31 PM
RE: How to handle checkboxes - by Rufnex - 11-24-2014, 02:36 PM
RE: How to handle checkboxes - by alexandervj - 11-24-2014, 02:50 PM
RE: How to handle checkboxes - by Rufnex - 11-24-2014, 02:52 PM
RE: How to handle checkboxes - by alexandervj - 11-24-2014, 02:57 PM
RE: How to handle checkboxes - by Rufnex - 11-24-2014, 03:07 PM
RE: How to handle checkboxes - by alexandervj - 11-24-2014, 03:48 PM
RE: How to handle checkboxes - by Rufnex - 11-24-2014, 03:52 PM
RE: How to handle checkboxes - by alexandervj - 11-24-2014, 03:55 PM
RE: How to handle checkboxes - by InsiteFX - 11-24-2014, 11:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB