Welcome Guest, Not a member yet? Register   Sign In
Best way to get validated form data into a database
#4

[eluser]Pascal Kriete[/eluser]
You're right, you definitely want to filter what you're inserting. I use something similar to this (in an extended form validation class):
Code:
/**
* Filters allowed post keys
*
* @access    public
* @param     post data
* @return     cleaned array
*/
function filter_input_data($data)
{
    $allowed = $this->_field_data;
    return array_intersect_key($data, $allowed);
}

Then use it like this:
Code:
$db_clean = $this->validation->filter_input_data($_POST);

[Edit: PHP >= 5.1 only]


Messages In This Thread
Best way to get validated form data into a database - by El Forum - 11-07-2008, 12:58 AM
Best way to get validated form data into a database - by El Forum - 11-07-2008, 02:59 AM
Best way to get validated form data into a database - by El Forum - 11-07-2008, 08:31 AM
Best way to get validated form data into a database - by El Forum - 11-07-2008, 08:50 AM
Best way to get validated form data into a database - by El Forum - 11-07-2008, 09:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB