Welcome Guest, Not a member yet? Register   Sign In
A problem loading a controller from a controller, I guess.
#1

[eluser]Unknown[/eluser]
Hey guys,
I m trying to worn on this code and it's giving me an error..

title bar : http://localhost/ci/index.php/contact/submit

Error:
Fatal error: Call to undefined method CI_Loader::controller() in G:\xampp\htdocs\ci\application\controllers\contact.php on line 17


Code :

Code:
<?php

class Contact extends CI_Controller{
function __construct(){
  parent::__construct();
}

function index(){
  $data['main_content'] = 'contact_form';
  $this -> load ->view('include/template', $data);
}

function submit(){
  $name = $this -> input -> post('name');
  $email = $this -> input -> post('email');
  
  $this -> load -> controller('Contact_aux');
  $result = $this -> contact_aux -> send();
  
  if(!$result){
  
  }
  else{
   $this -> load -> view('Signup_Confirmation_View');
  }
}
}





And the code for the contact_aux controller :

Code:
<?php

class Contact_aux extends CI_Controller{
function __construct(){
  parent::__construct();
}

function index(){
  
}

function send(){
  $this -> load -> library('form_validation');
  
  // field name, error message,  validation rules
  $this -> form_validation -> set_rules('name', 'Name', 'trim|required');
  $this -> form_validation -> set_rules('email', 'Email Address', 'trim|required|valid_email');
  
  if(($this -> form_validation -> run()) == FALSE){
   $this -> load -> controller('contact');
   return FALSE;
  
  }
  else{
   $name = $this -> input -> post('name');
   $email = $this -> input -> post('email');
   $feedback = $this -> input -> post('message');
  
   $this -> load -> library('email');
  
   $this -> email -> set_newline("\r\n");
  
   $this -> email -> from('[email protected]');
   $this -> email -> to($email);
   $this -> email -> subject('First Newsletter');
   $message_string = 'Thank you for your feedback Mr.'.$name;
   $message_string = $message_string.'\r\nYour Feedback that u gave is : \r\n';
   $message_string = $message_string.$feedback;
   $this -> email -> message($message_string);
  
   if($this -> email -> send()){
    // echo 'Congrats! Your Email is sent.';
    //$this -> load -> view('Signup_Confirmation_View');
    return TRUE;
   }
   else{
    show_error($this -> email -> print_debugger());
    return FALSE;
   }
  }
  
  
  
  
}
}



Any help will be appreciated.




Theme © iAndrew 2016 - Forum software by © MyBB