わかりましたので、登録プロセスに生年月日セクションを追加しました。私はおそらく奇妙な方法でそれをしましたが、それは私の心の中でそれを行う論理的な方法であるため、それが機能する限り、私はそれで問題ありません. 3 つの dob フィールド (dob1、dob2、dob3 - 月、日、年) を作成しました。私が今抱えている問題は、ユーザーが dob 値をデータベースに正しく保存していないことを登録したときです (値はランダムなようで、乱数と文字として表示されます)。だから私は自分が間違っていることに興味があります。これが私がやったことです。
編集: 問題は見つかりましたが、まだ解決策を探しています。どこか順番がバラバラです。メールの最初の 2 文字は dob1 に入り、パスワードの最初の 2 文字は dob2 に入ります (合格か確認合格かはわかりません)、dob1 は firstname に、dob2 は lastnam に、ユーザー名は問題ありません。そのため、配列の順序をどこかで混同しましたが、それがどこで重要かはわかりません。
EDIT2: 私の問題を見つけました。答えは以下です。
controllers/auth.php に関数を登録します。
function register()
{
if ($this->tank_auth->is_logged_in()) { // logged in
redirect('');
} elseif ($this->tank_auth->is_logged_in(FALSE)) { // logged in, not activated
redirect('/auth/send_again/');
} elseif (!$this->config->item('allow_registration', 'tank_auth')) { // registration is off
$this->_show_message($this->lang->line('auth_message_registration_disabled'));
} else {
$use_username = $this->config->item('use_username', 'tank_auth');
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_le\
ngth', 'tank_auth').']|alpha_dash');
}
$this->form_validation->set_rules('dob1', 'DOB1', 'trim|required|xss_clean|min_length[2]|max_length[2]');
$this->form_validation->set_rules('dob2', 'DOB2', 'trim|required|xss_clean|min_length[2]|max_length[2]');
$this->form_validation->set_rules('dob3', 'DOB3', 'trim|required|xss_clean|min_length[2]|max_length[4]');
$this->form_validation->set_rules('firstname', 'First Name', 'trim|xss_clean|min_length[2]|max_length[50]');
$this->form_validation->set_rules('lastname', 'Last Name', 'trim|xss_clean|min_length[2]|max_length[50]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');
$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email|callback_is_email_domain[ku.edu]');
$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]');
$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('dob1'),
$this->form_validation->set_value('dob2'),
$this->form_validation->set_value('dob3'),
$this->form_validation->set_value('firstname'),
$this->form_validation->set_value('lastname'),
$this->form_validation->set_value('email'),
$this->form_validation->set_value('password'),
$email_activation))) { // success
$data['site_name'] = $this->config->item('website_name', 'tank_auth');
$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('dob1'),
$this->form_validation->set_value('dob2'),
$this->form_validation->set_value('dob3'),
$this->form_validation->set_value('firstname'),
$this->form_validation->set_value('lastname'),
$this->form_validation->set_value('email'),
$this->form_validation->set_value('password'),
$email_activation))) { // success
$data['site_name'] = $this->config->item('website_name', 'tank_auth');
if ($email_activation) { // send "activate" email
$data['activation_period'] = $this->config->item('email_activation_expire', 'tank_auth') / 3600;
$this->_send_email('activate', $data['email'], $data);
unset($data['password']); // Clear password (just for any case)
$this->_show_message($this->lang->line('auth_message_registration_completed_1'));
} else {
if ($this->config->item('email_account_details', 'tank_auth')) { // send "welcome" email
$this->_send_email('welcome', $data['email'], $data);
}
unset($data['password']); // Clear password (just for any case)
$this->_show_message($this->lang->line('auth_message_registration_completed_2').' '.anchor('/auth/login/', 'Login'));
}
} else {
$errors = $this->tank_auth->get_error_message();
foreach ($errors as $k => $v) $data['errors'][$k] = $this->lang->line($v);
}
}
if ($captcha_registration) {
if ($use_recaptcha) {
$data['recaptcha_html'] = $this->_create_recaptcha();
} else {
$data['captcha_html'] = $this->_create_captcha();
}
}
$data['use_username'] = $use_username;
$data['captcha_registration'] = $captcha_registration;
$data['use_recaptcha'] = $use_recaptcha;
$this->load->view('auth/register_form', $data);
}
}
ライブラリ: Tank_Auth.php - これが dob 全体ではないことはわかっていますが、この関数を呼び出しても何も返されません。1 つの dob を返すことができれば、簡単にすべてを返すことができます。編集: このファイルのすべての変更を含めていないことに気付きました。
else {
$this->ci->session->set_userdata(array(
'user_id' => $user->id,
'dob1' => $user->dob1,
'dob2' => $user->dob2,
'dob3' => $user->dob3,
'firstname' => $user->firstname,
'lastname' => $user->lastname,
'username' => $user->username,
'status' => ($user->activated == 1) ? STATUS_ACTIVATED : STATUS_NOT_ACTIVATED,
));
. . .
function get_dob()
{
return $this->ci->session->userdata('dob1');
}
. . .
function create_user($username, $firstname, $lastname, $email, $password, $email_activation, $dob1, $dob2, $dob3)
{
if ((strlen($username) > 0) AND !$this->ci->users->is_username_available($username)) {
$this->error = array('username' => 'auth_username_in_use');
$hashed_password = $hasher->HashPassword($password);
$data = array(
'firstname' => $firstname,
'lastname' => $lastname,
'dob1' => $dob1,
'dob2' => $dob2,
'dob3' => $dob3,
'username' => $username,
'password' => $hashed_password,
'email' => $email,
ビュー: registration_form.php
<?php
if ($use_username) {
$username = array(
'name' => 'username',
'id' => 'username',
'value' => set_value('username'),
'maxlength' => $this->config->item('username_max_length', 'tank_auth'),
'size' => 30,
);
}
$email = array(
'name' => 'email',
'id' => 'email',
'value' => set_value('email'),
'maxlength' => 80,
'size' => 30,
);
$firstname = array(
'name' => 'firstname',
'id' => 'firstname',
'value' => set_value('firstname'),
'maxlength' => 50,
'size' => 30,
);
$lastname = array(
'name' => 'lastname',
'id' => 'lastname',
'value' => set_value('lastname'),
'maxlength' => 50,
'size' => 30,
);
$password = array(
'name' => 'password',
'id' => 'password',
'value' => set_value('password'),
'maxlength' => $this->config->item('password_max_length', 'tank_auth'),
'size' => 30,
);
$confirm_password = array(
'name' => 'confirm_password',
'id' => 'confirm_password',
'value' => set_value('confirm_password'),
'maxlength' => $this->config->item('password_max_length', 'tank_auth'),
'size' => 30,
);
$dob1 = array(
'name' => 'dob1',
'id' => 'dob1',
'value' => set_value('dob1'),
'maxlength' => 2,
'size' => 30,
);
$dob2 = array(
'name' => 'dob2',
'id' => 'dob2',
'value' => set_value('dob2'),
'maxlength' => 2,
'size' => 30,
);
$dob3 = array(
'name' => 'dob3',
'id' => 'dob3',
'value' => set_value('dob3'),
'maxlength' => 4,
'size' => 30,
);
$captcha = array(
'name' => 'captcha',
'id' => 'captcha',
'maxlength' => 8,
);
?>
<?php echo form_open($this->uri->uri_string()); ?>
<table>
<?php if ($use_username) { ?>
<tr>
<td><?php echo form_label('Username', $username['id']); ?></td>
<td><?php echo form_input($username); ?></td>
<td style="color: red;"><?php echo form_error($username['name']); ?><?php echo isset($errors[$username['name']])?$errors[$username['name']]:''; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo form_label('Email Address', $email['id']); ?></td>
<td><?php echo form_input($email); ?></td>
<td style="color: red;"><?php echo form_error($email['name']); ?><?php echo isset($errors[$email['name']])?$errors[$email['name']]:''; ?></td>
</tr>
<tr>
<td><?php echo form_label('First Name', $firstname['id']); ?></td>
<td><?php echo form_input($firstname); ?></td>
<td style="color: red;"><?php echo form_error($firstname['name']); ?><?php echo isset($errors[$firstname['name']])?$errors[$firstname['name']]:''; ?></td>
</tr>
<tr>
<td><?php echo form_label('Last Name', $lastname['id']); ?></td>
<td><?php echo form_input($lastname); ?></td>
<td style="color: red;"><?php echo form_error($lastname['name']); ?><?php echo isset($errors[$lastname['name']])?$errors[$lastname['name']]:''; ?></td>
</tr>
<tr>
<td><?php echo form_label('Password', $password['id']); ?></td>
<td><?php echo form_password($password); ?></td>
<td style="color: red;"><?php echo form_error($password['name']); ?></td>
</tr>
<tr>
<td><?php echo form_label('Confirm Password', $confirm_password['id']); ?></td>
<td><?php echo form_password($confirm_password); ?></td>
<td style="color: red;"><?php echo form_error($confirm_password['name']); ?></td>
</tr>
<tr>
<td><?php echo form_label('Date of Birth', $dob1['id']); ?></td>
<td><?php echo form_input($dob1); ?></td>
<td><?php echo form_input($dob2); ?></td>
<td><?php echo form_input($dob3); ?></td>
<td style="color: red;"><?php echo form_error($dob1['name']); ?><?php echo isset($errors[$dob1['name']])?$errors[$dob1['name']]:''; ?></td>
</tr>
<?php if ($captcha_registration) {
if ($use_recaptcha) { ?>
<tr>
<td colspan="2">
<div id="recaptcha_image"></div>
</td>
<td>
<a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a>
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div>
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div>
</td>
</tr>
<tr>
<td>
<div class="recaptcha_only_if_image">Enter the words above</div>
<div class="recaptcha_only_if_audio">Enter the numbers you hear</div>
</td>
<td><input type="text" id="recaptcha_response_field" name="recaptcha_response_field" /></td>
<td style="color: red;"><?php echo form_error('recaptcha_response_field'); ?></td>
<?php echo $recaptcha_html; ?>
</tr>
<?php } else { ?>
<tr>
<td colspan="3">
<p>Enter the code exactly as it appears:</p>
<?php echo $captcha_html; ?>
</td>
</tr>
<tr>
<td><?php echo form_label('Confirmation Code', $captcha['id']); ?></td>
<td><?php echo form_input($captcha); ?></td>
<td style="color: red;"><?php echo form_error($captcha['name']); ?></td>
</tr>
<?php }
} ?>
</table>
<?php echo form_submit('register', 'Register'); ?>
<?php echo form_close(); ?>
**また: registration_form.php の td タグの幅を変更する方法を知っている場合は、お知らせください。シンプルでもうまくいかないことに苦労しています。