I have a function called _check_input
. Any _GET
functions I call, always get parsed into my _check_input
function. Is this enough to have a fully secure .php file so I don't get hacked?
function _check_input($string) {
if (!preg_match("/^[A-Za-z0-9]+$/", $string)) {
echo "ERROR";
exit();
} else {
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
}
$input = _check_input($_GET['input']);
All my program does is strcmp the input against a .json file I have using file_get_contents
. It loops through the .json until it finds a match. Once it has a match, it goes to a specific value in the .json and prints it out.
PS: I am a new programmer