Welcome Guest, Not a member yet? Register   Sign In
sending emails
#1

[eluser]maru[/eluser]
Hi everyone!

I have this model and I get the email which I want to send

Code:
class People_Model extends CI_Model{

public function getInfo($id){

$this->db->select('*');
    $this->db->from('people');

    $query = $this->db->get();

    if($query->num_rows() > 0)
    {
        foreach ($query->result_array() as $row)
        {
            return $row['email'];
        }
    }
    else
    {
        return FALSE;
    }
}
}

and in my controller

Code:
$this->load->model('people_model', 'people');

$clientInfo = $this->people->getInfo($id);

$this->email->from('[email protected]', 'My Title');
$this->email->to($clientInfo);  

$this->email->subject('My Subject');
$this->email->message('Your User is '.$clientInfo.' and your Password is '.$pass); // I can get the email but $pass of course can't get any value in this case.

$this->email->send();

I need some help here because I can get the email and it can send it perfectly but in the message I need to send the password also and I don't know how I can get it from the model.
thanks in advance!
#2

[eluser]Ckirk[/eluser]
Try this:
Code:
class People_Model extends CI_Model{

public function getInfo($id){

$this->db->select('*');
    $this->db->from('people');

    $query = $this->db->get();

    if($query->num_rows() > 0)
    {
        foreach ($query->result_array() as $row)
        {
            return $row;  //return the whole row instead of just the email
        }
    }
    else
    {
        return FALSE;
    }
}
}

Now you have the whole 'people' record so:
Code:
$this->load->model('people_model', 'people');

$clientInfo = $this->people->getInfo($id);

$this->email->from('[email protected]', 'My Title');
$this->email->to($clientInfo);  

$this->email->subject('My Subject');
$this->email->message('Your User is '.$clientInfo['email'].' and your Password is '.$clientInfo['password']); // I can get the email but $pass of course can't get any value in this case.

$this->email->send();
#3

[eluser]maru[/eluser]
Ckirk thank u so much for your help! it works!!!




Theme © iAndrew 2016 - Forum software by © MyBB