Browse Source

Form validation added

master
Rogier Neeleman 9 years ago
parent
commit
cc8fd5551c
  1. 2
      application/config/autoload.php
  2. 11
      application/controllers/login.php
  3. 1
      application/views/login.php

2
application/config/autoload.php

@ -58,7 +58,7 @@ $autoload['packages'] = array();
| |
| $autoload['libraries'] = array('user_agent' => 'ua'); | $autoload['libraries'] = array('user_agent' => 'ua');
*/ */
$autoload['libraries'] = array(); $autoload['libraries'] = array('form_validation');
/* /*
| ------------------------------------------------------------------- | -------------------------------------------------------------------

11
application/controllers/login.php

@ -15,8 +15,17 @@ class Login extends CI_Controller
// Header // Header
$this->load->view('header'); $this->load->view('header');
// Content $this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE)
{
// login page
$this->load->view('login'); $this->load->view('login');
} else {
echo "Done";
}
// Footer // Footer
$this->load->view('footer'); $this->load->view('footer');

1
application/views/login.php

@ -8,6 +8,7 @@
<div class='col_3'> <div class='col_3'>
</div> </div>
<div class='col_4 right'> <div class='col_4 right'>
<?php echo validation_errors(); ?>
<?php echo form_open(base_url('login/')); ?> <?php echo form_open(base_url('login/')); ?>
<label for='text2'>Username:</label> <label for='text2'>Username:</label>
<?php echo form_input('username'); ?><br> <?php echo form_input('username'); ?><br>

Loading…
Cancel
Save