Welcome Guest, Not a member yet? Register   Sign In
Form_validation help!
#1

[eluser]Rogier[/eluser]
I just can't figure out what i'm doing wrong... I'm new to Codeigniter so maybe it's a simple mistake but please help me.. For somekind of reason the callback won't work.....

Thanks....

class Site extends Controller {

function __construct() {

parent::__construct();

$this->load->library(array('session', 'form_validation'));

$this->load->helper(array('url', 'form'));

$this->load->database();

}

function index() {

redirect('site/subscribe');

}

function subscribe() {

$this->load->model('mdl_subscribe');

if ($this->mdl_subscribe->validate()) {

if ($this->mdl_subscribe->create('camp_subscribers', 'sub_name', 'sub_email', $this->input->post('sub_name'), $this->input->post('sub_email'))) {

echo 'email send';

}
}

$this->load->view('site');

}




---- the model -----

class Mdl_subscribe extends MY_Model {

public function __construct() {

parent::__construct();

}

public function validate() {

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

$this->form_validation->set_rules('sub_name', 'Subscriber name', 'trim');

$this->form_validation->set_rules('sub_email', 'Subscriber email', 'trim|required|valid_email|callback_check_subscribers');

return parent::validate();

}

public function create($table, $sub_name_field, $sub_email_field, $sub_name, $sub_email) {

$db_array = array(
$sub_name_field => $sub_name,
$sub_email_field => $sub_email,
'sub_active' => '0',
'sub_hash' => md5($sub_email)
);

$this->db->insert($table, $db_array);

return TRUE;

}

public function check_subscribers($mail) {

return FALSE;

//this i just did for the tryout later on i want to check if emailadress already exists in database

}

}


Messages In This Thread
Form_validation help! - by El Forum - 12-23-2010, 04:51 PM
Form_validation help! - by El Forum - 12-23-2010, 10:48 PM
Form_validation help! - by El Forum - 12-23-2010, 11:06 PM
Form_validation help! - by El Forum - 12-24-2010, 01:42 AM
Form_validation help! - by El Forum - 12-24-2010, 01:55 AM
Form_validation help! - by El Forum - 12-24-2010, 01:59 AM
Form_validation help! - by El Forum - 12-24-2010, 02:25 AM
Form_validation help! - by El Forum - 12-24-2010, 03:49 AM
Form_validation help! - by El Forum - 12-24-2010, 03:54 AM
Form_validation help! - by El Forum - 12-24-2010, 04:01 AM
Form_validation help! - by El Forum - 12-24-2010, 04:07 AM
Form_validation help! - by El Forum - 12-24-2010, 04:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB