Guys,
After a while and lots of research (and some help from you), I could manage to send an e-mail to a list from my database.
To do that, with GC, I added an action button "send email". So it will send that object to the list.
This is the action button:
$crud->add_action('Send e-mail', $icone_send_email, 'painel/enviar_emkt', '');
So it calls a function/method called 'enviar_emkt';
After all the checks and select from DB, I send the e-mail and finally I return to the function 'criar_email' that creates the Grocery Crud table and renders it at the page.
This is the 'enviar_emkt' code that send me back to ''criar_email' function:
public function enviar_emkt($id) { $this->load->database(); $this->db->select('id, assunto, texto, nome_arquivo')->from('emkt_mkt')->where('id', $id); $query = $this->db->get()->row_array(); $img ="assets/emkt/img/".$query['nome_arquivo']; $assunto = ucfirst($query['assunto']); //$config( 'e-mail configuration' ) $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('from email', 'from name'); $this->email->subject($assunto); $this->email->message($mensagem); $list = ""; $list = $this->lista_emkt(); // get the email list from database for($i = 0; $i < count($list); $i++){ $this->email->to( $list[$i]['email']); if( $this->email->send() ){ // log; }else{ // log; } } //attenpt to clear the variables $this->email->clear(); $lista = NULL; $id = NULL; // return to main page $this->criar_email(); }
So far it is good, I can get back to the GC table.
But, at the browser URL still points to the url/function/id of the last email sent, like in the action button.
This way, if I send an e-mail and try to add another data in the table, it will send the e-mail again.
This is the url from brower when I get back from sending e-mails:
localhost/news/painel/enviar_emkt/26
(should be localhost/news/painel/criar_email )
Does this happened to someone? How do I solve it?
Thanks (again).