[eluser]ian[/eluser]
My View:
Code:
<h2><?php echo lang('user_login_header') ?></h2>
<?php echo form_open('users/login', array('id'=>'login')); ?>
<?php if (validation_errors()): ?>
<div class="error-box"><?php echo validation_errors();?></div>
<?php endif; ?>
<ul class="reset">
<li class="field">
<label for="email"><?php echo lang('user_email')?></label>
<input type="text" name="email" maxlength="120" value="<?php echo $user_data->email; ?>" />
</li>
<li class="field">
<label for="password"><?php echo lang('user_password')?></label>
<input type="password" name="password" maxlength="20" value="<?php echo $user_data->password; ?>" />
</li>
<li class="field checkboxes">
<?php echo form_checkbox('remember', '1', FALSE, 'class="checkbox"'); ?> <label for="remember"><?php echo lang('user_remember')?></label>
</li>
</ul>
<div class="buttons">
<input class="submit" type="submit" value="<?php echo lang('user_login_btn') ?>" name="btnLogin" />
</div>
<?php echo form_close(); ?>
<p><?php echo anchor('users/reset_pass', lang('user_reset_password_link'));?> | <?php echo anchor('register', lang('user_register_btn'));?></p>
My Controller Function:
Code:
public function login()
{
// Get the user data
$user_data = (object) array(
'email' => $this->input->post('email'),
'password' => $this->input->post('password')
);
// Validation rules
$this->validation_rules = array(
array(
'field' => 'email',
'label' => lang('user_email_label'),
'rules' => 'required|trim|callback__check_login'
),
array(
'field' => 'password',
'label' => lang('user_password_label'),
'rules' => 'required|min_length[6]|max_length[20]'
),
);
// Set the validation rules
$this->form_validation->set_rules($this->validation_rules);
// Set the redirect page as soon as they get to login
if(!$this->session->userdata('redirect_to'))
{
$uri = parse_url($this->input->server('HTTP_REFERER'), PHP_URL_PATH);
// If iwe aren't being redirected from the userl ogin page
$root_uri = BASE_URI == '/' ? '' : BASE_URI;
strpos($uri, '/users/login') !== FALSE || $this->session->set_userdata('redirect_to', str_replace($root_uri, '', $uri));
}
// If the validation worked, or the user is already logged in
if ($this->form_validation->run() or $this->ion_auth->logged_in())
{
$redirect_to = $this->session->userdata('redirect_to')
? $this->session->userdata('redirect_to')
: ''; // Home
$this->session->unset_userdata('redirect_to');
// Call post login hook
$this->hooks->_call_hook('post_user_login');
// Redirect the user
redirect($redirect_to);
}
// Render the view
$this->data->sBodyClass = 'one-col';
$this->data->user_data =& $user_data;
$this->template->build('login', $this->data);
}
My .htaccess
Code:
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 200
# Error Logging
php_flag display_errors on
php_value error_reporting 9
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#RewriteBase /wherever/pyro/is
# Keep people out of codeigniter directory and Git/Mercurial data
RedirectMatch 403 ^/(application\/cache|codeigniter|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
I'll be happy to post anything from my config.php file, but I don't want to post the whole thing if not necessary.
I noticed I wasn't able to login to the page, so I initially thought it was a Session problem, but the first thing I tried was to print out the variables I was passing. Trying to print to the error log with
Code:
log_message('error', $this->input->post('email'));
gave me nothing.
When I put
Code:
var_dump($user_data);
after filling that array in the first few lines of the login() function, I get this printed out:
object(stdClass)#36 (2) { ["email"]=> bool(false) ["password"]=> bool(false) }