• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation library usage for form validation. Need help

I am using Validation library as autoload. Now problem is when I type in URL
http://localhost/CIB/test/ get error below and if browse http://localhost/CIB/test/check_user working fine.
I understand that default values are required if not calling check_user.
But I don't want to call check_user as default instead I want to call default index at start and once
user click button than check_user should be called. Am I right here?

So whats the solution here?. Should I use defaults in order call index at start? if yes whats the professional way to code
when there are many fields.


A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Validation::$username_error
Filename: views/test_view.php
Line Number: 11

A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Validation::$username
Filename: views/test_view.php
Line Number: 12

//CONTROLLER called test.php
class Test extends Controller {

    function index()

        function  check_user()

            if ($this->validation->run() == FALSE)

        function _set_fields()
                $fields['username']    = 'Username';

        function _set_rules()
                $rules['username']    = "required";
                $this->validation->set_message('required', '%s required');


//VIEW called test_view.php
<title>My Form</title>

<?php echo $this->validation->error_string; ?>
<?php echo form_open('form/check_user'); ?>

&lt;?php echo $this->validation->username_error; ?&gt;
&lt;input type="text" name="username" value="&lt;?php echo $this-&gt;validation->username;?&gt;" size="50" />

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>
<br /><br />

&lt;?php echo form_close()?&gt;


[eluser]Thorpe Obazee[/eluser]
Try using the new Form validation

Thanks for the reply. Form_Validation library is working but I want to use Validation library thats why asking solution to my problem. Sad

Validation library is deprecated in 1.7.2 (removed in 2.0) and replaced with form_validation, so you're not going to get much help with it.

Got it

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.