Welcome Guest, Not a member yet? Register   Sign In
Form Validation: Custom Callback Rule Problem...

(This post was last modified: 09-20-2018, 01:04 PM by ryan_f.)

Hey--I've set up a custom Form Validation Callback fairly similar to the "username" example shown in the Manual. 

Everything seems to be working great except when I load the page(this is the 2nd page of the form) I have the Error message come up on the First attempt. 

Why is this happening and what can I do to avoid this?

Code for setting callback up:
('header_1', 'Header 1', 'callback_bigsearch_check');

Callback Function:
function bigsearch_check($header_1)
$query_example = $this->db->query("
Header = '$header_1'

if($query_example->num_rows() == 0)
'That Item is not Found in the Database,
Please Select One from the dropdown'

return FALSE;
return TRUE;

Callback function


You are doing something wrong with the run() method.
PHP Code:
if( $this->form_validation->run() === TRUE )
// Everything OK
// First run, load view.

You also got a SQL Injection in your code. Use Query binding.

You mention that this is the 2nd page of your form. I guess the form_validation rule is applied after you post the 1st page.
Please, share the logic in your controller that handles the form pages and $_POST result.
And please, don't paste your php code as plain text in the forum editor. There's a button for php code in the button bar. If you use that, you make the code much better readable for everyone.

Theme © iAndrew 2016 - Forum software by © MyBB