Welcome Guest, Not a member yet? Register   Sign In
form validation
#1

[eluser]maniac[/eluser]
I am trying to do a login to an administration section on a website using codeigniters validation, but keep coming up with errors -

Undefined property: CI_Loader::$validation

Trying to get property of non-object

both on my view page, but can't seem to see where I have gone wrong (reading user guide for libraries and validation), so any help would be appreciated.

My view page -

Code:
<?php echo $this->validation->error_string; ?>
  
      <?php echo form_open('form'); ?>
  
      <p>User Name
      &lt;input type="text" name="username" value="&lt;?php echo $this-&gt;validation->username;?&gt;" /></p><br />
  
      <p>Password
      &lt;input type="password" name="password_2" value="&lt;? echo $this-&gt;validation->password_2;?&gt;" /></p>
      <br />
      &lt;input type="submit" name="submit" value="submit" /&gt;&lt;/p>
    &lt;/form&gt;

my controller -

Code:
function form()
        {
      $this->load->helper(array('form','url'));
      $this->load->library('validation');
      
      $rules['username']="trim|required|xss_clean";
      $rules['password_2']="trim|required|xss_clean";
      
      $this->validation->set_rules($rules);
      
      $fields['username']='username';
      $fields['password_2']='password_2';
      
      $this->validation->set_fields($fields);
      
      if($this->validation->run()==FALSE)
      {
        $this->load->view('adminLoginView');
      }
      else
      {
        $this->load->view('admin');
      }
    }

Thanks,
Maniac
#2

[eluser]mi6crazyheart[/eluser]
In u'r VIEW file use this...
Code:
&lt;?php echo validation_errors(); ?&gt;

instead of this
&lt;?php echo $this->validation->error_string; ?&gt;
#3

[eluser]InsiteFX[/eluser]
You should be using the new form validation library.

As of CI 1.7.0 the validation library has been deprecated!

CI 2.0 the validation library has been removed!

InsiteFX
#4

[eluser]maniac[/eluser]
Changed the view and still getting an error -

Call to undefined method CI_Loader::validation_errors()
#5

[eluser]maniac[/eluser]
What is the new validation library? I am using 1.7.2. Is the user manual wrong? I am now totally lost.

Do I just set up a html form and in the controller use the if(isset) coding?

Maniac
#6

[eluser]InsiteFX[/eluser]
Take a look at the Form Validation Class library in
the Users Guide

Code:
$this->load->library('form_validation');

// View
&lt;?php echo validation_errors(); ?&gt;

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB