It’s a well covered topic, but I’d like to get some confirmation on methods of using data from user variables, in a few different situations.
-
The variable is never used in a database, never stored, only displayed on screen for the user. Which function to use to make sure no html or javascript can screw things up?
-
The variable is taken into the database, and used in SQL queries.
-
The variable does both.
At the moment I xss_clean, and strip_tags. I’ve always done this, just by autopilot. Is there a better technique? Apologies if there’s an identical question out there. I kinda assume there is, although I couldn’t find one as thorough as this.
Cheers.
htmlspecialchars