I have a search function on my website. In addition, elsewhere I have a place where users can submit categories for their posts. I want the categories to have an uppercase first letter and the rest lower case. I know there far more complex ways to secure a user input string, but do you think that as a fairly basic function, this is relatively secure?
function purify_string($string){
$script_tags = "/\<script +(.+)<\/script>+/i";
$string = strip_tags(addslashes($string));
$string = preg_replace($script_tags, '', $string);
$string = trim($string);
$string = strtolower($string);
$string = ucfirst($string);
return $string;
}