XSS Prevention in PHP

Possible duplicate:
What are the best methods to prevent xss attacks on a php site

I need to prevent XSS attacks in PHP code, is there a good and simple library for this?

+7
php xss
source share
5 answers

Security is not a product. This is a process.

If you rely on a library for security, you are doomed to be attacked at one point or another.

Anyway, you can sanitize your inputs with standard php functions (i.e. htmlspecialchars() )

+11
source share

There are many PHP functions that can help you prevent XSS attacks. Look at them:

strip_tags

http://php.net/manual/en/function.strip-tags.php

htmlspecialchars

http://php.net/manual/en/function.htmlspecialchars.php

+4
source share

Theres a lot of good answers on google, at first I found; http://codeassembly.com/How-to-sanitize-your-php-input/

My main advice would be to consider each entry as a direct attack.

So convert to html characters. Add slashes.

+1
source share

htmlspecialchars()

-one
source share

All Articles