Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

apparently, some of our websites have been hacked by a hack bot. The reason: bad input sanitzation. Our boss is giving us this file to put on all our servers to secure them:

Personally, i just do this on my personal websites: filter_var(mysql_real_escape_string($_POST['Nom']), FILTER_SANITIZE_STRING);. So you tell me, which one is better and why?

share|improve this question
That is one of the worst sanitization functions i have ever seen! Are you actually passing html/sql through get/post vars??? – Gary Willoughby May 12 '11 at 12:32
omg Yesssssssss – mahen23 May 12 '11 at 12:39
How about you post a link to your websites so we can test how well your input sanitization works. >;) – FrustratedWithFormsDesigner May 12 '11 at 13:34

2 Answers 2

up vote 6 down vote accepted

Input sanitazion isn't just about "including a file and you're done"! It requires extensive knowledge about the system and starts with designing the processes accepting the data. Neither solution will solve all your problems. It might defend some attacks but certainly not all!

share|improve this answer

This is a pretty bad filter.

Use something standard if possible, like

Also, do white-list input validation, and output encoding.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.