Loading...
Monday, November 28, 2011

Protect against SQL Injection

There are more ways.. 1 of them is-

with blocking the SQL commands
function mysqlesc($input) { 

$input = str_ireplace('\'', '', $input);

$input = str_ireplace('"', '', $input);

$input = str_ireplace('UNION', '', $input); 

$input = str_ireplace('--', '', $input); 

$input = str_ireplace('/**/', '', $input); 

$input = str_ireplace('/*', '', $input); 

return $input; }

another protecting method is:

function mysqlesc($input){
$input = mysql-real-escape-string($input);

return $input;
}

0 comments:

Post a Comment

 
TOP