Results 1 to 2 of 2
Jun 27, 2012, 18:49 #1
- Join Date
- Apr 2012
- 1 Post(s)
- 0 Thread(s)
Best way save user input in database(RTE)
i have been working with a RTE and my current cleaning function trim(strip_tags(stripslashes())). I use PDO for inserting data in to the database, so i am not one hundred % sure on how i should go with the RTE text area input. I am not sure how i should clean that input, or if i should just use htmlenties to display it in a safe way in the website.
Jun 29, 2012, 04:32 #2
- Join Date
- Oct 2006
- France, deep rural.
- 17 Post(s)
- 1 Thread(s)
If you use PDO's prepared statements to protect your database from injection, and you then use htmlentities to protect your users from XSS attacks, then you ought to be fine.
As for "cleaning that input", this will only work when you know exactly what is going to be allowed and you either filter out everything else, or detect and infringement and abort that operation -- so called Filtering Input (FIEO)
e.g. a phone number. You might permit spaces, dashes, round brackets and numbers.
For a free for all text area you face an impossible task, so you simply have to protect each environment from attack by Escaping Output. (FIEO)