0

重複の可能性:
PHP で SQL インジェクションを停止する最良の方法

助けを求めてグーグルで検索してみましたが、想像していたほど簡単ではありません。誰かが SQL を保護する方法を教えてくれたり、自分でそれを行う方法を学べる優れた Web サイトへのリンクを教えてくれたりできたら.

あなたが親切にもそれを修正し、何が間違っていたのかを教えてくれれば、私は間違いなくメモを取って残りのコードを保護します.

    <?php
    $post = htmlspecialchars($_GET["id"]);
    $results = mysql_query("SELECT * FROM tool WHERE id = $post");
    $authorr = $_SESSION['Username'];

while($row = mysql_fetch_array($results)){
 $capsd = ucfirst($author);
 $title= $row['title'];
 $details= $row['details'];
 $author= $row['author'];
 $date= $row['date'];
 $img= $row['featuredimage'];
 $id= $row['id'];



    echo "<table border=1><tr><td width=100px>
                 <b><u><center>";
    echo $title;
    echo "</center></u></td> <td width=100px><center>";
    echo $date;
    echo "</center></td> <td width=100px><b><center>";
    echo ucfirst($author);
    echo "</center></b></td>";

    if (in_array($authorr, $allowedposters)) {
    echo "<center><td width=20px><a href=edit.php?id=";
    echo $id;
    echo "><b>Edit</b></a></center></td>";
    }
   echo "</tr></table>";
   echo "<img src=http://www.removed.com/news/";
   echo $img;
   echo " height=300 width=400> <br><br>";
   echo $details;

   }
   ?>
4

1 に答える 1

0

これを見てください: PHP で SQL インジェクションを防ぐにはどうすればよいですか?

基本的に、答えは、準備されたステートメントを使用し、入力をサニタイズすることです。

于 2012-05-26T06:11:01.857 に答える