Welcome Guest, Not a member yet? Register   Sign In
send post form data through email class
#11

[eluser]InsiteFX[/eluser]
Ya because you need to get the input post in the retrive_password method because that is were you are posting it to.

I am going to get some sleep but I will be on later.
#12

[eluser]swgj19[/eluser]
It worked! All I did was just use one controller. I just deleted the redirect and merged the email controller with the retieve controller Because I already got the input method in my model. Thanks Ray. Here is the whole code to help others.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Retrieve extends CI_Controller {

function index()
{
  $data['main_content'] = 'forgot_password';        //create new key 'main_content, which turns into a variable, pass in view you want to load
  $this->load->view('includes/template', $data);
}
function retrieve_password()
{  
  $this->load->model('membership_model');          //load membership model
  $query = $this->membership_model->retrieve();        //call method
  
  if($query) // if the user's credentials validated...      //if user's credentials are validated...
  {
   $data = array(               //then create new data equal to array
    'username' => $this->input->post('username'),      
               //add value to session
   );                  //is_logged_in is function in site controller
   $this->load->view('send_password_link');

// Email retrieve password link to users posted email

  //$this->load->library('email');

  $config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.googlemail.com',
      'smtp_port' => 465,
      'smtp_user' => '[email protected]',
      'smtp_pass' => '********',
      'charset' => "utf-8",
      'mailtype' => "html",
      'newline' => "\r\n"

    );

    $this->load->library('email', $config);
    $this->form_validation->set_rules('email_address', 'Email', 'trim|required');
$email = $this->input->get_post('email_address');
    $this->email->set_newline("\r\n"); /* for some reason it is needed */

    $this->email->from('[email protected]', 'Aditya Lesmana Test');
    $this->email->to($email);  
    $this->email->subject('This is an email test');
    $this->email->message('it is working Darling');

    if($this->email->send())
    {
      echo 'Your email was sent';
      //var_dump($email);
    }
    else
    {
      show_error($this->email->print_debugger());
    }      
  }
  else // incorrect username or password
  {
  
  
   $this->index();
                //load index.php if login was not correct or nothing returned from db
  }

}
}
           //load index.php if login was not correct or nothing returned from db

Here is my model:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Membership_model extends CI_Model {

function validate()
{
  $this->db->where('username', $this->input->post('username'));  //validate username
  $this->db->where('password', md5($this->input->post('password'))); //validate password
  $query = $this->db->get('membership');        //get db table
  
  if($query->num_rows == 1)           //Make sure data in table exist
  {
   return true;             //if data in table, then return results
  }
}
function create_member()
  {
  $new_member_insert_data = array(         //if validation passed (line 57 controller/login.php), post array data to db
   'first_name' => $this->input->post('first_name'),
   'last_name' => $this->input->post('last_name'),
   'email_address' => $this->input->post('email_address'),
   'username' => $this->input->post('username'),
   'password' => md5($this->input->post('password'))  //make sure password is md5 or same in db
   );
  
   $insert = $this->db->insert('membership', $new_member_insert_data); //insert (insert is new_member_insert_data array) into membership table
   return $insert;
  }
  function retrieve()
{
  $this->db->where('email_address', $this->input->post('email_address'));  //validate username
  $query = $this->db->get('membership');        //get db table
  
  if($query->num_rows == 1)           //Make sure data in table exist
  {
   return true;             //if data in table, then return results
  }
}
}




Theme © iAndrew 2016 - Forum software by © MyBB