Welcome Guest, Not a member yet? Register   Sign In
get value from query and put on controller
#1

[eluser]ranggadablues[/eluser]
Hallo..

first sorry for my english.
I just create a contact form, I want for email to is dynamic that I can change for the email on my admin panel setup,the question is can I get value from query and put on controller here the script
Code:
function contact()
{  
  $data['email'] = $this->Pgallery_model->getEmail();
  
  $this->form_validation->set_rules('email','Email','trim|required|valid_email');
    
  if ($this->form_validation->run()==FALSE){  
   $this->load->view('contact', $data);
   } else {
    $config['protocol'] = 'sendmail';
    $config['mailtype'] = 'text';
    $config['charset'] = 'utf-8';
    $config['wordwrap'] = TRUE;
    $this->email->initialize($config);
    
    $this->email->to(/*here the query value*/);
    
    $this->email->send();    
    $this->load->view('contact_sukses', $data);
  }
}

here for my model
Code:
function getEmail()
{
  $query = $this->db->query('select email from setup');
  return $query->result();
}
I want
Code:
$this->email->to(/*here the query value*/);
get result on own controller, please help. Thank you
#2

[eluser]InsiteFX[/eluser]
Code:
function contact()
{  
  $data['email'] = $this->Pgallery_model->getEmail();
  
  $this->form_validation->set_rules('email','Email','trim|required|valid_email');
    
  if ($this->form_validation->run()==FALSE){  
   $this->load->view('contact', $data);
   } else {
    $config['protocol'] = 'sendmail';
    $config['mailtype'] = 'text';
    $config['charset'] = 'utf-8';
    $config['wordwrap'] = TRUE;
    $this->email->initialize($config);
    
    $this->email->to($data['email']);
    
    $this->email->send();    
    $this->load->view('contact_sukses', $data);
  }
}
#3

[eluser]ranggadablues[/eluser]
thank you for the reply, but it show some error :
Quote:A PHP Error was encountered

Severity: Warning

Message: preg_match() expects parameter 2 to be string, object given

Filename: libraries/Email.php

Line Number: 795
Quote:A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: libraries/Email.php

Line Number: 272
Quote:A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: libraries/Email.php

Line Number: 282
so, which part is wrong? thank you
#4

[eluser]InsiteFX[/eluser]
Because that is what you are returning change it to return and array.

Code:
function getEmail()
{
  $query = $this->db->query('select email from setup');
  return $query->row_array();
}
#5

[eluser]ranggadablues[/eluser]
[quote author="InsiteFX" date="1342424493"]Because that is what you are returning change it to return and array.

Code:
function getEmail()
{
  $query = $this->db->query('select email from setup');
  return $query->row_array();
}
[/quote]

wooww..!!!
it works!!!
thank you..but, how to change this topic is solved?
#6

[eluser]InsiteFX[/eluser]
Edit it and add [SOLVED] to Title.
#7

[eluser]ranggadablues[/eluser]
[quote author="InsiteFX" date="1342430647"]Edit it and add [SOLVED] to Title.
[/quote]
I've got Error Message :long:
#8

[eluser]InsiteFX[/eluser]
What error message?
#9

[eluser]ranggadablues[/eluser]
[quote author="InsiteFX" date="1342433425"]What error message?
[/quote]
Quote:Error Message

Due to a heavy increase of spam within our community, the privilege of posting certain content is currently reserved for active community members and those who have purchased our software.

If you feel you have received this in error, please contact [email protected] with a support key of 9bsu7cfd-bvwog88w-sogs8gg4-s8080ks for more information.
#10

[eluser]InsiteFX[/eluser]
You should be able to now, they do have a limit of 10 posts.




Theme © iAndrew 2016 - Forum software by © MyBB