0

Here is my code

$success = $this->user_model->get_user($user_id);
//$success variable contains some array values 
if($success){
    $this->email->from('[email protected]'));
    $this->email->to($success->email);
    $this->email->subject('New user registration and update');
    $message = $this->load->view('email/view_adduser', $success, true);
    $this->email->message($message);
    $this->email->send();
 }

Email is sucessfully sent, but data aren't displaying there. And here is my email view template(email/view_adduser.php)

<h2>Hello Sir/Madam</h2><br />
<p>Your Login credientials are provided below</p><br />
<p>Please <a href="<?php echo base_url().'admin'; ?>" >Login</a> 
To access your account </p><br />
<p>Username & Password : - <?php echo $success->username;?></p><br />

Here username is not displaying in the email. Anybody have any idea??? Thanks in advance

2
  • Are you positive the array contains the proper data? Maybe try using var_dump($success) and see what is displayed. Commented Aug 29, 2014 at 22:41
  • 1
    You should be using $username in the view as CI converts it for you Commented Aug 29, 2014 at 22:41

1 Answer 1

1

If you want to access the data in your view as $success->username then you should wrap the user object in an array when passing it to the view like this:

$message = $this->load->view('email/view_adduser', array('success' => $success), true);

Otherwise you can access the data directly without the $success object, i.e: $username instead of $success->username

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.