When youve got a form and people submit information which gets put into a database what safety precautions need to be taken so that the data isnt dangerous? By this I mean what functions...
Examples are:
htmlspecialchars()
addslashes()
etc....
What others are advisable...
Comments
SQL injection occurs when you do not addslashes to data you are using in queries. For example, take this query for example: If you do not addslashes to the user inputted data, they could enter data that will malform the query and get it to return true no matter what (thus, in that example, the user might gain admin accesS) So add_slashes protect against that just fine.
The malicious code occurs when a user inserts some kind of script that will be run on a victims computer. For example, say you have a comments system and you let your members use HTML. Let's also say you authenticate members and store their username /password hash in a cookie. A malicious user could use javascript to get a hold of the username and password hash (where it could be cracked):
You can either write complex expressions to filter out those kinds of attacks, or simply disable all HTML (which htmlspecialchars does).
So all in all:
Webmaster-Talk.com
Chroder.com
Its a good job Ive always used them two then
The Royal Ram