Ahojte. Uz dlhsiu dobu na internete hladam nejaky dobry a jednoduchy skript, ako sa ochranit pred SQL injection v PHP skriptoch. Pouzivam MySQL a chcel by som co najviac zabranit MySQL injekcii, preto sa pytam tu vas skusenejsich.
Dakujem za kazdu odpoved.
Fórum › MySQL
SQL injection

nebo pokud používáš php tak taky addslashes a kdzž máš mít číselnou hodnotu tak to přikazem format převect jenom na čísla a když má byt řetězec tak jenom řetězec - kažždopádně zakázat ' a " a podobný svinstvo
Anonymous
Nebo používej nějakou abstrakční vrstu, která ti vstupy ošetří – PDO[1], dibi[2] atp.
[1] http://php.net/pdo
[2] http://dibiphp.com/
Takze som pozeral PHP manual o spominanych funkciach
mysql_escape_string() a mysql_real_escape_string().
Z toho mi vyplyva, ze ak pred kazdym mysql_query() zavolam mysql_real_ecscape_string($string), malo by to uz byt takmer 100% ochranene proti MySQL injection. Dalej som sa docital, ze musim zistovat $_GET aj $_POST.
Takze bude to bezpecne?
PS: Je nebezpezne, ked mysql_real_escape_string() ne-escapuje "%" a "_" ?
To bl4z4 : Mně osobně se hodně osvědčila funkce htmlentities($str, ENT_QUOTES) -> vechno, co se dá převést, tak převede na entity
Já kontroluji data tak, že je použiji funkci htmlspecialchars a poté funkci test_sql.
function test_sql($teststring){
$teststring=strtr($teststring," ","x");
$teststring=strtr($teststring,"+","x");
$teststring=strtr($teststring,"--","x");
$teststring=strtr($teststring,"&","x");
return ($teststring);
}

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Sql injection — založil Paja2
SQL Injection - moje řešení - prolomíte jej? — založil MartinB84
Upravte mi prosím PHP script proti XSS a SQL Injection — založil Jošta
Ošetření ' a " znaků, obrana proti SQL Injection a dalším takov… — založil Lighter
Osetreni "SQL injection " — založil Ruda
Moderátoři diskuze