Still injectable if I'm reading the preg string right. You need to filter ', or you can just do this:
PHP Code:
public function Clean($var)
{
$unpacked = unpack('H*hex', $var);
$hex = '0x' . $unpacked['hex'];
if($hex == "0x")
$hex = "0x00"; // null to avoid syntax error
return $hex;
}
// optional alphanumeric check:
if(preg_match("/[^a-z0-9]/", "", $_POST['username']) > 0)
{
// notify user that username must be alphanumeric
exit;
}
$username= Clean(preg_replace("/[^a-z0-9]/", "", $_POST['username']));
$encryptedpw = Clean(md5($hash . $_POST['password']));
$get01 = mssql_query("SELECT * FROM [ACCOUNT_TBL] WHERE account=$username");
$row01 = mssql_fetch_assoc($get01);
$get02 = mssql_query("SELECT * FROM [ACCOUNT_TBL_DETAIL] WHERE account=$username");
$row02 = mssql_fetch_assoc($get02);