php - Do I need to use mysql_real_escape_string on all form inputs? -


i know need use them on user input fields such username entry field, radio buttons such gender option?

stop!

you seem confusing escaping data validation , data sanitization.

you need validate data comes in. yes, means making sure radio buttons contain legal values.

you need sanitize data comes in. should text field contain html? no? strip_tags. should field number? cast integer.

you need escape data place in database. if you're still using prehistoric "mysql" extension, means using mysql_real_escape_string on as build query -- not before.

you need escape data echo user. htmlspecialchars friend.

i've explained in more detail, though not duplicate question.


Comments

Popular posts from this blog

how to build hyperlink for query string in php -

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

queue - mq_receive: message too long -