I want to make sure my sanitize doesnt have any leaks in it. And also, im only outputting user-data within hardcoded p tags and h1 tags
eg : <p><?php echo htmlspecialchars($user_data); ?></p>
So is this a safe way to protect me against XSS-injects.
First, im using this function to sanetize the data before it gets inserted into my DB, and while in my DB im using bind_param
function sanitize($str) {
return strtolower(strip_tags(trim(($str))));
}
sanitize($user_data); - > then gets inserted into db
Then when I grap the data from the DB I am using this to show it.
<p> <?php echo htmlspecialchars($user_data); ?> </p>
So, is this a safe way to block any XSS?
Thanks!