我在tank auth.Field的一個註冊表格中添加了兩個字段,名稱爲fname和lname。 我已經在form_validation中添加了你可以看到的控制器文件。但是用戶名,密碼,電子郵件被注入數據庫期望fname和lname.What在代碼中是錯誤的嗎?我已經檢查過,如果字段的名稱,他們是正確的。表單驗證也正常,但數據庫字段名稱也是fname和lname.Can有人找出問題。已經坐了很長時間,但無法找到它們工作在codeignitor tank auth中沒有保存數據庫的值
auth.php控制器是
if ($use_username) {
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|min_length['.$this->config->item('username_min_length', 'tank_auth').']|max_length['.$this->config->item('username_max_length', 'tank_auth').']|alpha_dash');
}
$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|min_length['.$this->config->item('password_min_length', 'tank_auth').']|max_length['.$this->config->item('password_max_length', 'tank_auth').']|alpha_dash');
$this->form_validation->set_rules('confirm_password', 'Confirm Password', 'trim|required|xss_clean|matches[password]');
$this->form_validation->set_rules('fname', 'First Name', 'trim|required|xss_clean'); // I added
$this->form_validation->set_rules('lname', 'Last Name', 'trim|required|xss_clean'); //I added
$captcha_registration = $this->config->item('captcha_registration', 'tank_auth');
$use_recaptcha = $this->config->item('use_recaptcha', 'tank_auth');
if ($captcha_registration) {
if ($use_recaptcha) {
$this->form_validation->set_rules('recaptcha_response_field', 'Confirmation Code', 'trim|xss_clean|required|callback__check_recaptcha');
} else {
$this->form_validation->set_rules('captcha', 'Confirmation Code', 'trim|xss_clean|required|callback__check_captcha');
}
}
$data['errors'] = array();
$email_activation = $this->config->item('email_activation', 'tank_auth');
if ($this->form_validation->run()) { // validation ok
if (!is_null($data = $this->tank_auth->create_user(
$use_username ? $this->form_validation->set_value('username') : '',
$this->form_validation->set_value('fname'),//I added
$this->form_validation->set_value('lname'),
$this->form_validation->set_value('email'),
$this->form_validation->set_value('password'),
$email_activation)))
user.php的模型
function create_user($data, $activated = TRUE)
{
$data['created'] = date('Y-m-d H:i:s');
$data['activated'] = $activated ? 1 : 0;
if ($this->db->insert($this->table_name, $data)) {
$user_id = $this->db->insert_id();
if ($activated) $this->create_profile($user_id);
return array('user_id' => $user_id);
}
return NULL;
}