CodeIgniter Forums

Full Version: Blank Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]stuffradio[/eluser]
I'm trying to email a user when someone submits a comment to an image. It was working fine until I started doing the email part. Any ideas why it's giving me a blank page?

If there is some lines of code commented out, it's because I was trying to debug what it could be.

Btw: It doesn't even echo Test on the page

Code:
function comment()
  {
    if ($this->loginlib->checkSession())
    {
    $this->comments->photo_id = $this->input->post('photo_id', true);
    $theUsername = $this->comments->getOwner();
    $this->users->username = $theUsername->username;
    $getUser = $this->users->get();


     if ($this->comments->permission())
     {
    $this->comments->poster = $this->session->userdata('logged_in');
    $this->comments->comment = $this->input->post('comment', True);
    $this->comments->posted = date("Y-m-d");
    //$this->comments->insert();
    if ($getUser->allow_comments == "true")
    {
    $this->sendemaillib->to = $getUser->email;
    $this->sendemaillib->from = '[email protected]';
    $this->sendemaillib->fromName = $getUser->fName . ' ' . $getUser->lName;
    $this->sendemaillib->subject = 'You got a new comment on an image!';
    $this->sendemaillib->message = 'This is a test message!';
    //$this->sendemaillib->sendIt();
    }
    redirect('/picture/id/'.$this->comments->photo_id);
     }
     }
    echo "test";
  }

Code:
function getOwner()
  {
    if ($this->photo_id)
    {
      $poster = $this->db->get_where('pb_photos', array('id' => $this->photo_id));
      $post_id = $poster->row();
      $check = $this->db->get_where('project_users', array('username' => $post_id->poster));
      
      return $check->row();
    } else {
     return false;
    }
  }

Code:
<?php

class Sendemaillib
{

  var $to;
  var $from;
  var $fromName; // First and Last name of You
  var $subject;
  var $message;

  function Sendemaillib()
  {
    $this->CI =& get_instance();
    $this->CI->load->library('email');
  }

  function sendIt()
  {
    if (isset($this->to) && isset($this->from) && isset($this->subject) && isset($this->message))
    {
      $this->email->to($this->to);
      $this->email->from($this->from, $this->fromName);
      $this->email->subject($this->subject);
      $this->email->message($this->message);
      $this->email->send();
      $errors = array('error' => 'Email sent successfully to' . $this->to . '!');
      return $errors;
    } else {
      $errors = array('error' => 'Not everything is set!');
      return $errors;
    }

    }

}