Stop making ads for another forum.
Now i tell how to fix SQL-Injection
First of all you need to put the escape function into a PHP File which is includet into all of your scripts. Best way is the php file where your database connection is.
Escape Function:
Code:
function ms_escape($data) {
if(!isset($data) or empty($data)) return '';
if(is_numeric($data)) return $data;
$non_displayables = array(
'/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
'/%1[0-9a-f]/', // url encoded 16-31
'/[\x00-\x08]/', // 00-08
'/\x0b/', // 11
'/\x0c/', // 12
'/[\x0e-\x1f]/' // 14-31
);
foreach($non_displayables as $regex)
$data = preg_replace($regex,'',$data);
$data = str_replace("'","''",$data);
return $data;
}
Know you are able to use escape functon.
Now an example.
Code:
"SELECT* FROM [PS_UserData].[dbo].[Users_Master] WHERE [UserID] = $_POST['userid'];"
With this query a "hacker" is able to inject some bad code.
The fixxed way should be like this:
Code:
$userid = ms_escape($_POST['userid']);
Code:
"SELECT* FROM [PS_UserData].[dbo].[Users_Master] WHERE [UserID] = $UserID;"
I know that the SQL-Querys which i postet have a syntax error. With a bit of PHP experience you should be able to fix it.
Regards