Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Codigo seguro SQL INJECTION

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Dica Codigo seguro SQL INJECTION

    Código PHP:
    <?php    

    if(isset($_GET['enviar'])){

        


        
    $id mysql_real_escape_string(stripslashes($_GET['id']));

        if (
    is_numeric($id)){

        
    $sql="SELECT titulo, texto FROM noticias WHERE noticias_id = '$id'";
        
    $resultado=mysql_query($sql) or die('<pre>' mysql_error() . '</pre>' );

        
    $num=mysql_num_rows($resultado);

        
    $i=0;

        while (
    $i $num) {

            
    $titulo=mysql_fetch_array($resultado,$i,"titulo");
            
    $texto=mysql_fetch_array($resultado,$i,"texto");
            
            echo 
    '<pre>';
            echo 
    'ID: ' $id '<br>Titulo da noticia:: ' $titulo '<br>Texto da noticia: ' $texto;
            echo 
    '</pre>';

            
    $i++;
        }
        }
    }
    ?>
    -------------------------------------------------------------------------------------------






    Similar Threads

  • Font Size
    #2
    muito util vai me ajudar numas minhas brincadeiras que gosto de fazer otimo post

    Comment


    • Font Size
      #3
      desculpa a burriçe mas pra que que serve esse codigo D:

      Comment


      • Font Size
        #4
        exemplo no site ele ficaria "noticia.php?id="
        seria uma forma segura anti sql injection
        -------------------------------------------------------------------------------------------






        Comment


        • Font Size
          #5
          atah uma forma de evitar invasões por sql injection interessante obrigado (:

          Comment

          X
          Working...
          X