posted 03/4/2008 by Chris

Any input that you get from a user should be cleaned for malicious code. Here are some simple functions that will help...

 

- used to remove blank spaces from front and end of text

trim($user_input)

 

- used to remove all html/javascript tags

strip_tags($user_input)

 

- used to store any non-alphanumeric characters into a database safely

htmlentities($user_input, ENT_QUOTES)

 

- used when getting text from a database to add the non-alphanumeric characters back in

html_entity_decode($database_text, ENT_QUOTES)

Tags: security / php / code
Share:
facebook myspace digg del.icio.us fark stumbleupon live spurl furl reddit yahoo

COMMENTS (displaying 0 comments)

POST (leave a comment)

Name:
Email:
Message:
Verify:
CAPTCHA Image