[eluser]ali oygur[/eluser]
hi,
Sorry, im little speak english my from turkey.
i have a problem about form_validation callback.
form validation callback function not work in my class.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* @Package : Gazale kimlik doğrulandırma kütüphanesi (gazale_auth)
* @Author : Ali OYGUR
* @Link : www.adagrafik.com
* @Version : 1.0.0
* Last update : 17.05.2010
*/
class Gazale_auth{
var $CI;
function __construct()
{
$this->CI =& get_instance();
$this->CI->load->library('session');
$this->CI->load->library('form_validation');
// $this->CI->load->helper('url');
$this->CI->load->database();
// $this->CI->load->helper('email');
// $this->CI->load->helper('string');
}
/*
* YENİ ÜYE KAYDI
*/
function new_user()
{
# Kurallara uygunluk kontrolü
$this->CI->form_validation->set_rules('username', 'Kullanıcı adı', 'trim|required|min_length[3]|max_length[150]|htmlspecialchars|callback__username_exists');
$this->CI->form_validation->set_rules('password', 'Şifre', 'trim|required|min_length[4]|matches[password2]|md5');
$this->CI->form_validation->set_rules('password2', 'Şifre tekrarı', 'trim|required');
$this->CI->form_validation->set_rules('email', 'E mail', 'trim|required|htmlspecialchars|valid_email|callback__email_exists');
if($this->CI->form_validation->run() === FALSE):
$returns = array('error' => TRUE, 'msg' => $this->CI->form_validation->error_string());
else:
$table = 'user';
$data = array
(
'id' => NULL,
'username' => $this->CI->input->post('username'),
'password' => $this->CI->input->post('password'),
'email' => $this->CI->input->post('email'),
'last_visit' => date('Y-m-d H:i:s'),
'avatar' => 'avatar_yok.gif',
'date' => date('Y-m-d H:i:s')
);
$insert = $this->CI->db->insert('user', $data);
if($insert):
$returns = array('error' => FALSE);
$this->CI->session->set_flashdata('status', 'Üyelik işleminiz başarı ile tamamlanmıştır. Şimdi aşağdaki forumdan giriş yapabilirsiniz');
else:
$returns = array('error' => TRUE, 'msg' => 'Kayıt esnasında bir problem oluştu. lütfen bunu '.$this->CI->config->item('mh_mail').' adresine bildirin.');
endif;
endif;
return $returns;
}
/*
* ÜYE BİLGİLERİ
* herhangi bir üye id verilmezse sessionda kayıtlı üye id 'ye ait üye bilgilerini çeker.
* verilirse verilen üye id ye ait bilgileri çeker.
*/
function get_userdata($user_id = NULL)
{
if(is_null($user_id)) $user_id = $this->CI->session->userdata('user_id');
$query = $this->CI->db->get_where('user', array('id' => $user_id));
$user_data = $query->row();
return $user_data;
}
/*
* //ÜYE BİLGİLERİ
*/
/*
* ORTAK FONKSİYONLAR
*/
# Sistemde bu isimle kayıtlı herhangi bir üye olup olmadığına bakılıyor
function _username_exists($username)
{
$table = 'user';
$where = array('username' => $username);
$query = $this->CI->db->get_where($table, $where);
if($query->num_rows() > 0):
$return = false;
$this->CI->form_validation->set_message('_check_username', 'Bu kullanıcı adı sistemde zaten kayıtlı');
else:
$return = true;
endif;
return $return;
}
but this code working in controller file.
Please help me