I'm sure this will be a very simple issue to solve but I can't get my head around what's going wrong.
I have the following code when the form is submitted.
$error = array();
$data = array(
'recipe_name' => utf8_normalize_nfc(request_var('recipe_name', '', true)),
'recipe_desc' => utf8_normalize_nfc(request_var('recipe_desc', '', true)),
);
// Validate user input
$validate_array = array(
'recipe_name' => array('string', true, 5, 25),
'recipe_desc' => array('string', true, 5, 25),
);
$error = validate_data($data, $validate_array);
recipe_name contains "name test" recipe_desc contains "desc test"
When I submit the form I get a server error.
Where am I going wrong? I've searched for examples on validating data but I still can't pinpoint what I'm doing wrong.
Adding var_dum($data) gives
array(2) { ["recipe_name"]=> string(4) "test" ["recipe_desc"]=> string(7) "testing" }
Adding var_dump($validate_array) gives
array(2) { ["recipe_name"]=> array(4) { [0]=> string(6) "string" [1]=> bool(true) [2]=> int(5) [3]=> int(10) } ["recipe_desc"]=> array(4) { [0]=> string(6) "string" [1]=> bool(true) [2]=> int(5) [3]=> int(25) } }
I hadn't included the user functions page in mine, so wasn't able to access the function, hence causing the server error. Knew it had to be something simple.
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
Adding the above fixed the problem.