我想提交一个文本区域,用户可以在其中输入与用户输入的文本格式相同的任何或任何特殊字符。与空格一样,新行和新选项卡在新行的开头。我有一个下面的代码,但当用户输入包含',",(,)它显示sqlquery错误。请让我知道如何插入文本如论坛到数据库。
html是
<textarea class="noticearea" name="notice_area" id="notice_area" ></textarea>php是
$noticeinsert = mysql_query("INSERT INTO notice_board(notice_id, notice_area, notice_dnt) VALUES ('$notice_id', '$notice_area', '$notice_dnt')"); 请让我知道如何提交任何输入值到数据库。另外,将html或php代码或用户输入的特定字符发送到数据库是否安全?
发布于 2013-09-13 10:04:58
你忘了$_POST。
变化
$noticeinsert = mysql_query("INSERT INTO notice_board(notice_id, notice_area, notice_dnt) VALUES ('$notice_id', '$notice_area', '$notice_dnt')"); 至
$noticeinsert = mysql_query("INSERT INTO notice_board(notice_id, notice_area, notice_dnt) VALUES ('$_POST["notice_id"]', '$_POST["notice_area"]', '$_POST["notice_dnt"]')"); 但是,检查$_POST变量,因为sql-注入。
https://stackoverflow.com/questions/18783544
复制相似问题