【发布时间】:2013-07-20 14:30:42
【问题描述】:
我对sql注入不熟悉,我想知道我的脚本中是否有任何无懈可击的地方,如果有请指出并给我一些修复它的提示。
<?php
include("config.php");
?>
<?php
$desc = $_POST['desc'];
$desc = mysql_real_escape_string($desc);
$author = $_POST['author'];
$date = date("d/M/Y");
mysql_query("INSERT INTO `changelog`(`author`, `date`, `description`) VALUES ('{$author}','{$date}','$desc')") or die(mysql_error());
include("success.php");
?>
【问题讨论】:
-
-1。 StackOverflow 既不是用来判断某人的代码,也不是用来发现人们代码中的错误或安全问题。不过我们可以回答问题。
-
是的,Don't use
mysql_*functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial.
标签: php sql code-injection