Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. array(0) {
  2.  
  3. <?php echo form_open("auth/login");?>
  4. <div class="form-group">
  5. <div class="input-group">
  6. <span class="input-group-addon"><i class="fa fa-user"></i>
  7. </span>
  8. <?php echo form_input($identity);?>
  9. </div>
  10. </div>
  11. <div class="form-group">
  12. <div class="input-group">
  13. <span class="input-group-addon"><i class="fa fa-lock"></i>
  14. </span>
  15. <?php echo form_input($password);?>
  16. </div>
  17. </div>
  18. <button type="submit" class="btn btn-primary text-theme-xs mr-8">Login</button>
  19. <?php echo form_checkbox('remember', '1', FALSE, 'id="remember"');?>
  20. <a href="<?= site_url('auth/forgot_password') ?>" class="text-theme-xs pull-right a-black">Forgot your password ?</a>
  21. </form>
  22.  
  23. function login()
  24. {
  25. $this->data['title'] = "Login";
  26.  
  27. //validate form input
  28. $this->form_validation->set_rules('identity', 'Identity', 'required');
  29. $this->form_validation->set_rules('password', 'Password', 'required');
  30.  
  31. if ($this->form_validation->run() == true)
  32. {
  33. //check to see if the user is logging in
  34. //check for "remember me"
  35. $remember = (bool) $this->input->post('remember');
  36.  
  37. if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
  38. {
  39. //if the login is successful
  40. //redirect them back to the home page
  41. $this->session->set_flashdata('message', $this->ion_auth->messages());
  42. redirect('/', 'refresh');
  43. }
  44. else
  45. {
  46. //if the login was un-successful
  47. //redirect them back to the login page
  48. $this->session->set_flashdata('message', $this->ion_auth->errors());
  49. redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
  50. }
  51. }
  52. else
  53. {
  54. //the user is not logging in so display the login page
  55. //set the flash data error message if there is one
  56. $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
  57.  
  58. $this->data['identity'] = array('name' => 'identity',
  59. 'id' => 'identity',
  60. 'type' => 'text',
  61. 'class' => 'form-control',
  62. 'value' => $this->form_validation->set_value('identity'),
  63. 'placeholder' => 'Username',
  64. );
  65. $this->data['password'] = array('name' => 'password',
  66. 'id' => 'password',
  67. 'type' => 'password',
  68. 'class' => 'form-control',
  69. 'placeholder' => 'Password',
  70. );
  71. $this->_render_page('templates/head', $this->data);
  72. $this->_render_page('templates/navbar', $this->data);
  73. $this->_render_page('auth/login', $this->data);
  74. $this->_render_page('templates/footer', $this->data);
  75. }
  76. }
  77.  
  78. <form action="http://www.mydomain.uk/auth/login" method="post" accept-charset="utf-8">
  79.  
  80. <p>
  81. <label for="identity">Email/Username:</label> <input type="text" name="identity" value="" id="identity" class="form-control" placeholder="Username" />
  82. </p>
  83.  
  84. <p>
  85. <label for="password">Password:</label> <input type="password" name="password" value="" id="password" class="form-control" placeholder="Password" />
  86. </p>
  87.  
  88. <p>
  89. <label for="remember">Remember Me:</label> <input type="checkbox" name="remember" value="1" id="remember" />
  90. </p>
  91.  
  92.  
  93. <p><input type="submit" name="submit" value="Login" />
  94. </p>
  95.  
  96. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement