token - class.phpmailer.php not in a defined site error -
even though had saved phpmailer_5.2.4 file inside codeigniter_2.2.0, showing class.phpmailer.php not there in local disk. , have confirmed class.phpmailer.php there in phpmailer_5.2.4.
my code follows:
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); require('phpmailer_5.2.4/class.phpmailer.php'); class site extends ci_controller { public function __construct(){ parent::__construct(); $this->load->model('site_model'); //$this->load->helper('url'); } public function index(){ $this->load->view('welcome'); } public function view(){ $this->load->view('registration'); } public function generate_token ($len){ // array of potential characters, shuffled. $chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); shuffle($chars); $num_chars = count($chars) - 1; $token = ''; // create random token @ specified length. ($i = 0; $i < $len; $i++){ $token .= $chars[mt_rand(0, $num_chars)]; } return $token; } public function insert(){ $token=$this->generate_token(7); $this->load->site_model->insert($token); } }
when require file in codeigniter's controller, file require (phpmailer_5.2.4/class.phpmailer.php) should in same directory current file (i guess controller file site.php), directory structure should this:
/ci-dir/application [dir] /ci-dir/application/controllers [dir] /ci-dir/application/controllers/site.php /ci-dir/application/controllers/phpmailer_5.2.4 [dir] /ci-dir/application/controllers/phpmailer_5.2.4/class.phpmailer.php /ci-dir/application/controllers/... /ci-dir/application/controllers/models ... /ci-dir/system if not case, , phpmailer_5.2.4 directory not inside controllers directory, should change require require correct location.
Comments
Post a Comment