Form validation returning FALSE |
10-15-2017, 10:23 AM
(This post was last modified: 10-15-2017, 10:27 AM by dwlamb. Edit Reason: clarity )
I discovered why FALSE is being returned but am at a loss to explain CI's state at the time my application seeks to validate the email address.
In core/Form_validation.php @ line 167 we have `public function set_rules` PHP Code: public function set_rules($field, $label = '', $rules = array(), $errors = array()) For that first if, $this->CI->input->method() must equal 'post'. The value is derived from $_SERVER['REQUEST_METHOD']. For some reason in my application the value is 'GET' [Case is irrelevant. method() does a case conversion on the value]. That state is despite having values in $_POST placed there by a form submission. I also know the data is in $_POST at the the time form validation runs after this set_rules function. Yes, PaulD name does equal 'email' in the $_POST and validation rule. In core/Form_validation.php public function run() line 422: PHP Code: public function run($group = '') From research as to how CI sets $_SERVER['REQUEST_METHOD']='POST' CI does so with the form helper using the form_open() function to create a semantic form opening tag with a method equal to 'post'. For now, this is my code: PHP Code: if (isset($_POST['email']) && !empty($_POST['email'])) { I added $_SERVER['REQUEST_METHOD']='POST';. The validation rule sets, validation can run and return TRUE. If someone can think of the reason $_SERVER['REQUEST_METHOD'] would equal GET, please enlighten me. I have another CI application which uses 3.0.6. That application also has a password reset system but the code is very different from the one above. Stepping through that code for form validation of a submitted e-mail address, $_SERVER['REQUEST_METHOD'] equals 'POST' as set by CI. |
Messages In This Thread |
Form validation returning FALSE - by dwlamb - 10-14-2017, 12:05 PM
RE: Form validation returning FALSE - by dave friend - 10-14-2017, 01:59 PM
RE: Form validation returning FALSE - by PaulD - 10-15-2017, 04:58 AM
RE: Form validation returning FALSE - by dwlamb - 10-15-2017, 10:23 AM
RE: Form validation returning FALSE - by dave friend - 10-15-2017, 11:46 AM
RE: Form validation returning FALSE - by dwlamb - 10-15-2017, 01:06 PM
RE: Form validation returning FALSE - by dave friend - 10-15-2017, 06:01 PM
RE: Form validation returning FALSE - by dwlamb - 10-15-2017, 06:45 PM
RE: Form validation returning FALSE - by dave friend - 10-16-2017, 08:21 AM
RE: Form validation returning FALSE - by gmgj - 04-17-2019, 11:38 AM
RE: Form validation returning FALSE - by gmgj - 04-30-2019, 03:48 PM
RE: Form validation returning FALSE - by dave friend - 05-01-2019, 09:56 AM
|