Here i have to write code to send mail to checked mail id's through checkbox with its value given as mail id's but problem arises while i pass the array of checkbox's value to controller via post method its not passing coz when i print the array it gives me an empty array, Please help me over this.
View.php
<?php $this->load->helper('form'); ?>
<?php $attributes = array("name" => "Sendquotation","autocomplete"=>"off");
echo form_open("Sendquotation/index", $attributes);?>
<div style="max-height: calc(50vh - 110px);overflow-y: scroll;" class="panel-body col-sm-12 form-group">
<h3 align="center">Select vendor you want to mail.<br><button class="btn btn-success text-right">Send all</button></h3>
<?php
foreach($vendorlist as $row)
{
echo '<input type="checkbox" name="vendor_name[]" value="'.$row->VendorEmail.'"> <b> '.$row->VendorName.'</b><hr/><br/>';
}
?>
</div>
<div class="col-sm-4 form-group">
<button type="submit" class="btn btn-success"><i class="fa fa-file-text"> </i> Send Enquery</button>
</div>
<?php echo form_close(); ?>
Controller.php
<?php
class Sendquotation extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
$this->load->library(array('session', 'form_validation'));
$this->load->database();
$this->load->model('Gst_model');
$this->load->model('User_model');
}
function index()
{
$vendor_mail= $this->input->post('vendor_name');
foreach ($vendor_mail as $mail_id)
{
$data = array(
'vendormailid' => $this->input->post('mail_id')
);
$config = array(
'protocol' => 'sendmail',
'mailtype' => 'html',
'charset' => 'UTF-8',
);
$this->load->library('email', $config);
$this->email->set_newline("
");
$this->email->set_mailtype("html");
$message =
'<h3>HTML MAIL</h3>';
$mail_to = "vendor@yourvendor.com";
$from_mail = 'kdk020313@gmail.com';
$from_name = 'EMERSON PVT LTD';
$reply_to = 'kdk020313@gmail.com';
$subject = "Online GSTIN Updation!";
$this->load->library('email', $config);
$this->email->from($from_mail, $from_name);
$this->email->to($data);
$this->email->cc('innovations@miisky.com');
$this->email->bcc('kdk020313@gmail.com');
$this->email->subject($subject);
$this->email->message($message);
//$this->email->attach($file);
if ($this->email->send()) {
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Mail Succesfully Sent!</div>');
//redirect('Purchase_master');
print_r($data);
}
}
}
}