Well, I was wondering when should I sanitize my code, when I add it to the database, or when it appears on my web page or both?
I ask this question because I sanitize my code before it is stored in the database, but I never sanitize it when it is displayed to the user.
Here is an example of how I sanitize my code before storing it in a database.
$title = mysqli_real_escape_string($mysqli, $purifier->purify(strip_tags($_POST['title']))); $content = mysqli_real_escape_string($mysqli, $purifier->purify($_POST['content']));
source share