Is this way secured to insert data to DB ?
$var = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["address"]), ENT_QUOTES, "ISO-8859-1"));
Is this way secured to insert data to DB ?
$var = mysql_real_escape_string(htmlspecialchars(stripcslashes($_POST["address"]), ENT_QUOTES, "ISO-8859-1"));
There is no "silver bullet".
But arguably one of the most effective ways to guard against SQL injection is to use prepared statements:
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
Another, equally effective defense is to use the most modern, secure mySql APIs available: either mySqli (object-oriented) or PDO SQL:
http://php.net/manual/en/mysqlinfo.api.choosing.php
Here is a link good link regarding SQL Injection, and how you can mitigate risks in your mySql code:
http://php.net/manual/en/security.database.sql-injection.php
Two guidelines I would strongly urge you to follow:
1) You should NOT use the old, deprecated mySql API for any new code. Use MySQLi or PDO instead.
2) You should NOT allow raw user input anywhere near a SQL statement. Carefully validate your input, and use prepared statements whenever possible.
IMHO...