Welcome Guest, Not a member yet? Register   Sign In
Form validation returning FALSE
#6

(10-15-2017, 11:46 AM)dave friend Wrote: You have just confirmed that "email" is set and not empty in the $_POST array, but $this->CI->input->method() !== 'post' in set_rules()? That does not make sense.

What does $_SERVER contain just before you explicitly set $_SERVER['REQUEST_METHOD']='POST';?

Does it look the same once you are in set_rules()?

Care to share the relevant part of the form's view? Or, at least confirm that the form method="post".

If I look at $_SERVER before or after the form is submitted it reads $_SERVER['REQUEST_METHOD']='GET';. At the point in the code after the form is submitted, when `if (isset($_POST['email']) && !empty($_POST['email']))` is TRUE, $_SERVER['REQUEST_METHOD']='GET';.

The only point in my code a SuperGlobal variable is manipulated by my code is the band-aid solution of `$_SERVER['REQUEST_METHOD']='POST'`.

$this->CI->input->method() !== 'post' in set_rules() does make sense if you look at the full context of 'public function set_rules' in core/Form_validation.php @ line 167 
PHP Code:
    public function set_rules($field, $label = '', $rules = array(), $errors = array())
    {
        // No reason to set rules if we have no POST data
        // or a validation array has not been specified
        if ($this->CI->input->method() !== 'post' && empty($this->validation_data))
        {
            return $this;
        } 
... 

if $this->CI->input->method() == 'get' it does not equal post.  The other half is true as well so the result is to not set validation rules for CI thinks there is nothing in $_POST.

The band-aid solution of $_SERVER['REQUEST_METHOD']='POST'; satisfies $this->CI->input->method() in set_rules for it does equal 'post' and will go on to perform the rest of the function (symbolized by '...' in PHP code above.)
Reply


Messages In This Thread
Form validation returning FALSE - by dwlamb - 10-14-2017, 12:05 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 dwlamb - 10-15-2017, 01:06 PM
RE: Form validation returning FALSE - by dwlamb - 10-15-2017, 06:45 PM
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



Theme © iAndrew 2016 - Forum software by © MyBB