且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在基于Ion Auth库的CodeIgniter中创建登录表单

更新时间:2022-12-07 10:01:03

config / routes.php

$route['login/check'] = 'auth/my_front_end_login';

查看

<?php echo form_open('login/check'); ?>

<fieldset>
    <legend>login Credentials<legend>

    <label for="identity">&lowast; Identity</label>
    <input type="text" name="identity" id="identity" value="<?php echo set_value('identity');?>" />
    <?php echo form_error('identity');?>

    <label for="password">&lowast; Password</label>
    <input type="password" name="password" id="password" value="<?php echo set_value('password');?>" />
    <?php echo form_error('password');?>

    <label for="message">&lowast; 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 / auth

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();
   }
}