Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> sql injection
slaw.omir
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 1
Dołączył: 10.08.2006

Ostrzeżenie: (0%)
-----


Mam pytanie czy poniższy kod w dużym stopniu zabezpieczy skrypt
przed atakiem sql injection

  1. <?php
  2. include('connect.php');
  3.  
  4. $kat=$_GET['kat'];
  5. $torba=$_GET['torba'];
  6.  
  7. $torba = mysql_real_escape_string($_GET['torba]);
  8.  
  9. if (! ereg ("[a-z-]$", $_GET['kat'])){
  10.  
  11. $ostrzezenie2='2';
  12.  
  13.  }else{
  14.  
  15. if($kat=='kategoria_a'){
  16.  
  17.  $zapytanie = mysql_query ("SELECT * FROM firmy_towar where kategoria = 'kategoria_a''")
  18. or die ("Zapytanie niepoprawne");
  19.  
  20. while ($row = mysql_fetch_array($zapytanie)){
  21. $id_f[]=$row["id_f"];
  22. $firma[]=$row["firma"];
  23. $stoisko[]=$row["stoisko"];
  24.  
  25. }
  26.  
  27.  
  28. }
  29.  
  30. else if (! ereg ("[a-z-]$", $_GET['$torba]))
  31.  
  32. {
  33.  
  34. $ostrzezenie2='2';
  35.  
  36.  }else{
  37.  
  38. $zapytanie = mysql_query ("SELECT * FROM firmy_lokalne where kategoria = '$torba'")
  39. or die ("Zapytanie niepoprawne");
  40.  
  41. while ($row = mysql_fetch_array($zapytanie)){
  42. $id_f[]=$row["id_f"];
  43. $firma[]=$row["firma"];
  44. $stoisko[]=$row["stoisko"];
  45.  
  46.  
  47. }
  48. }
  49.  
  50.  
  51. mysql_close($connect);
  52. ?>


W jaki sposób moge zabezpieczyć taki skrypt przed atakiem sql injection?


--------------------
--------------------------------------------------------------------------------------------------------------
https://www.web-development.com.pl - Tworzenie i pozycjonowanie stron internetowych
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 22:00