SQL injection is a technique often used to attack a web App .
This is done by including portions of SQL statements in a uper Input
areas . where a user can be disturb the sql statement and can be logged
in or attempt to accomplish the tasks that ther user want to perform
following are some examples which are very commonly used
to inject SQL statement
in the username we can input the string like this
1) ' or '1'='1
2) ' or '1'='1' -- '
3) ' or '1'='1' ({ '
4) ' or '1'='1' /* '
5) 1;DROP TABLE users
but now these days most of the web applications are injection free. but we can try
may be any where a chance to logged in without knowing username and password
How to prevent the injection
Ans : >> using mysql_real_escape_string($var_name); and you can replace every where the varriables which contains the string,
having single or double quotes with space/null just like str_replace("'","");
after that you can use string normally
$query = sprintf("SELECT * FROM `Users` WHERE UserName='%s' AND Password='%s'",
mysql_real_escape_string($Username),
mysql_real_escape_string($Password));
mysql_query($query);