[eluser]ivelin[/eluser]
Code:
<?php
class Log extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('Tpl', 'tpl');
}
function index() {
// $data['title'] = "My Real Title";
$data['sub'] = array(
'name' => 'Submit',
'id' => 'i',
'value' => '',
'type' => 'submit'
);
$this->tpl->view('login_form.tpl', $data);
}
function registration() {
$data['sub'] = array(
'name' => 'Submit',
'id' => 'i',
'value' => '',
'type' => 'submit'
);
$data['username'] = array(
'name' => 'Username',
'id' => 'username',
'value' => set_value('username')
);
$data['password'] = array(
'name' => 'Password',
'id' => 'password',
);
$data['password2'] = array(
'name' => 'Password2',
'id' => 'password2',
);
$data['email'] = array(
'name' => 'Email',
'id' => 'email',
'value' => set_value('email')
);
$this->tpl->view('reg_form.tpl', $data);
}
function validate_register() {
$this->load->library('form_validation');
$val = $this->form_validation;
$val->set_rules('Username', 'Username', 'trim|required|alpha_numeric|min_length[3]|max_length[13]|xss_clean');
$val->set_rules('Password', 'Password', 'trim|required|min_length[3]|max_length[23]|xss_clean');
$val->set_rules('Password2', 'Password2', 'trim|required|min_length[3]|max_length[23]|xss_clean|matches[password]');
$val->set_rules('Email', 'Email', 'trim|required|valid_email');
$val->set_error_delimiters('<p class="error">', '</p>');
if ($val->run()) {
if ($this->__check_username()) {
$this->load->model('users_model');
if ($this->users_model('insertUser')) {
$data['regSuccsess'] = 'Успешно се регистрирахте!';
} else {
$data['regSuccsess'] = 'Грешка при регистрирахте, опитайте пак!';
}
$this->tpl->view('reg_form.tpl', $data);
}
} else {
$this->registration();
}
}
function __check_username() {
$this->load->model('users_model');
if ($this->users_model->check_username()) {
echo 1;
return TRUE;
} else {
echo 0;
}
}
}
and View
Code:
<div id="forma">
{form_open('log/validate_register')}
<strong>{form_label($username.name)}</strong>
{form_input($username)}
{form_error($username.name)}
<strong>{form_label($password.name)}</strong>
{form_password($password)}
{form_error($password.name)}
<strong>{form_label($password2.name)}</strong>
{form_password($password2)}
{form_error($password2.name)}
<strong>{form_label($email.name)}</strong>
{form_input($email)}
{form_error($email.name)}
{form_submit($sub)}
{form_close()}
{$regSuccsess}
</div>
And I have the following problem :
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: regSuccsess
Filename: sysplugins/smarty_internal_data.php
how to solve? Thanks!