【发布时间】:2012-04-20 10:14:42
【问题描述】:
我需要使用 AJAX 将用户输入的 cmets 立即保存到数据库中。 这是评论框。
<div class="comment">
<form action="comment.php">
<textarea cols="35" name="comments"> Give us comment </textarea>
<input type="button" value="comment" onclick="ajaxFunction()">
</form>
</div>
这是php代码
<?php
$link = mysql_connect("localhost","root","");
mysql_select_db("continental_tourism");
$comments = $_POST['comments'];
if($comments == "")
echo "Please type your comment";
else
{
$query = "insert into comment(comment) values('$comments') ";
mysql_query($query);
}
return;
?>
我需要知道应该如何改变它。 谢谢你
【问题讨论】:
-
我认为有必要看到
ajaxFunction()。此外,如果您希望人们为您放下桌子,请询问。 SQL 注入不应该这么简单。请查看准备好的陈述。 -
需要在ajaxfunction()中发送数据
-
能否包含 ajaxFunction() 的代码?一般来说,你可以看看原型或jQuery之类的框架。
-
你见过this吗?
-
@David Z 我没有做 ajaxFunction。这就是我需要的:)
标签: php javascript mysql html ajax