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