Creating a CodeIgniter login form based on the Ion Auth library
I am still contributing to CodeIgniter.
I would like to create a login form for my codeigniter application based on the Ion Auth library .
I installed the library as instructed and it works fine when navigating auth / login, auth / create_user, auth / logout, etc.
However, I don't need a separate login page, I would like to embed the form on my home page. When I use the sample provided as a login on my home page, I get the following errors:
- Message: Undefined variable: message
- Message: Undefined variable: identity
- Message: Undefined variable: password
I understand that the above variables are not defined in my view, I just cannot figure out where and how they should be defined and why do they work fine in the provided sample that came with the library?
+3
source to share
3 answers
config / routes.php
$route['login/check'] = 'auth/my_front_end_login';
view
<?php echo form_open('login/check'); ?>
<fieldset>
<legend>login Credentials<legend>
<label for="identity">∗ Identity</label>
<input type="text" name="identity" id="identity" value="<?php echo set_value('identity');?>" />
<?php echo form_error('identity');?>
<label for="password">∗ Password</label>
<input type="password" name="password" id="password" value="<?php echo set_value('password');?>" />
<?php echo form_error('password');?>
<label for="message">∗ Message</label>
<input type="text" name="message" id="message" value="<?php echo set_value('message');?>" />
<?php echo form_error('message');?>
</fieldset>
<?php echo form_close();?>
Controllers / Authentication
public function my_front_end_login(){
if($this->form_validation->run('login_frontend')) // uses config/form_validation.php
{
//validation passed, now attempt login via ION_AUTH
//open ION_Auth library file and see what the login method requests in its params.
if(ION_Auth::login($params)) // Im not familiar with it
{
//login success
}
else
{
//login failure
}
}
else
{
$this->index();
}
}
0
source to share
<?php echo form_open('login/check'); ?>
<fieldset>
<legend>login Credentials<legend>
<label for="identity">∗ Identity</label>
<input type="text" name="identity" id="identity" value="<?php echo set_value('identity');?>" />
<?php echo form_error('identity');?>
<label for="password">∗ Password</label>
<input type="password" name="password" id="password" value="<?php echo set_value('password');?>" />
<?php echo form_error('password');?>
<label for="message">∗ Message</label>
<input type="text" name="message" id="message" value="<?php echo set_value('message');?>" />
<?php echo form_error('message');?>
</fieldset>
<?php echo form_close();?>
0
source to share