Kvashir Posted March 8, 2012 Share Posted March 8, 2012 Hi guys, first of all, sorry for my bad english I have a question, As title, how can i avoid html tags in a text passed by $_POST method? htmlentities() is one way, i think, but... there's another way to avoid me to use that? I don't like to decode again every text! Edit: is strip_tags(); good for this purpose? Quote Link to comment https://forums.phpfreaks.com/topic/258518-avoid-html-code-in-_post/ Share on other sites More sharing options...
creata.physics Posted March 8, 2012 Share Posted March 8, 2012 You are already on the right track with htmlentitties, you can also use htmlspecialchars(). This is the best way from having html code inserted through $_POST data. Quote Link to comment https://forums.phpfreaks.com/topic/258518-avoid-html-code-in-_post/#findComment-1325165 Share on other sites More sharing options...
scootstah Posted March 8, 2012 Share Posted March 8, 2012 htmlspecialchars() will let you view the HTML as plaintext, and strip_tags() will remove them completely. Quote Link to comment https://forums.phpfreaks.com/topic/258518-avoid-html-code-in-_post/#findComment-1325208 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.