Welcome Guest, Not a member yet? Register   Sign In
Need help
#1

[eluser]Unknown[/eluser]
Hi
I'm newbee in codeigniter and i have a problem with sending an email form.
I have a public function email in default controller with validation and succes send message which works ok.
Controller
Code:
public function contact()
{
  $this->load->model('judete');
  $this->load->model('zone');
  $this->load->model('localitati');
  
  $body_data['input_nume'] = array(
    'name' => 'nume',
    'class' => 'input',
    'value' =>  $this->input->post('nume')
  );
  $body_data['input_email'] = array(
    'name' => 'email',
    'class' => 'input',
    'value' => $this->input->post('email')
  );
  $body_data['input_telefon'] = array(
    'name' => 'telefon',
    'class' => 'input',
    'value' => $this->input->post('telefon')
  );
  $body_data['mesaj'] = array(
    'name' => 'mesaj',
    'class' => 'mesaj',
    'rows' => '10',
    'cols' => '40',
    'value' => $this->input->post('mesaj')
  );
  $body_data['submit'] = array(
    'value' => 'Trimite',
    'class' => 'submit',
    'name' => 'Submit'
  );
  $this->form_validation->set_rules('nume', 'Nume', 'trim|required|min_length[5]|max_length[30]|xss_clean');
  $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
  $this->form_validation->set_rules('telefon', 'Telefon', 'trim|required|min_length[10]|max_length[21]|numeric|xss_clean');
  $this->form_validation->set_rules('mesaj', 'Mesaj', 'trim|required|min_length[5]|max_length[500]|xss_clean');
  if ($this->form_validation->run() == FALSE)
  {
  
  //$body_data['captcahImage'] = $this->creatCaptcha();
  $body_data['judete']   = $this->judete->toate_judetele();
  $body_data['zone']    = $this->zone->toate_zonele();
  $body_data['background']  = rand(1,5);
  $body_data['cautare']   = rand(1,10);
  $body_data['title']    = " Contact";
  
  $layout_data['content_body']  = $this->load->view('front/contact', $body_data, true);
  $this->load->view('front/layout', $layout_data);
  }
  else
  {
   /* Send email*/
   $nume  = $this->input->post('nume');
   $email  = $this->input->post('email');
   $telefon = $this->input->post('telefon');
   $mesaj  = $this->input->post('mesaj');
  
   $this->load->library('email');
  
   $this->email->from($email, $nume);
   $this->email->to('contact@');
   //$this->email->cc('[email protected]');
   $this->email->subject('Email Contact ');
   $this->email->message($mesaj);
  
   $this->email->send();
  
   redirect('contact/ok', 'location');
  }
}

The view
Code:
<?=form_open('contact');?>
   &lt;?=form_error('nume', '<div class="error">', '</div><div class="cls"></div>')?&gt;
   <div  100px; height: 40px; float: left;"><b>*Nume:</b></div>
   <div  330px; height: 40px; float: left;">&lt;?=form_input($input_nume)?&gt;</div>
   <div class="cls" ></div>
  
   &lt;?=form_error('email', '<div class="error">', '</div><div class="cls"></div>')?&gt;
   <div  100px; height: 40px; float: left;"><b>*Email:</b></div>
   <div  330px; height: 40px; float: left;">&lt;?=form_input($input_email)?&gt;</div>
   <div class="cls" ></div>
  
   &lt;?=form_error('telefon', '<div class="error">', '</div><div class="cls"></div>')?&gt;
   <div  100px; height: 40px; float: left;"><b>*Telefon:</b></div>
   <div  330px; height: 40px; float: left;">&lt;?=form_input($input_telefon)?&gt;</div>
   <div class="cls" ></div>
  
   <div  430px; height: 20px; text-align: center;"><b>*Mesaj:</b></div>
   &lt;?=form_error('mesaj', '<div class="error">', '</div><div class="cls"></div>')?&gt;
   <div  430px; text-align: center;">&lt;?=form_textarea($mesaj)?&gt;</div>
   <div class="cls"  10px;"></div>
   <div  430px; height: 40px; text-align: center;">&lt;?=form_submit($submit)?&gt;</div>
  &lt;?=form_close()?&gt;
The problem is that i want to use this function to send email from within other public function from same controller and it returns me a blank page.
I have another public function in this controller which have different link segment pages based on URI.
All I want is to integrate email send function in one of this conditional link segment and send email form from here based on body data from here.
I hope i was explicit and sorry for the mistakes.




Theme © iAndrew 2016 - Forum software by © MyBB