http://blog.chinaunix.net/space.php?uid=21209537&do=blog&id=2722878
数据库表
message(id,email,content)
包括2个php页面:message.php(留言页面)和message_ajax.php(处理异步请求)
message.php
message_ajax.php
- <?php
-
$mysql = new SaeMysql();
-
$email = strip_tags($_POST['email']);
-
$content = strip_tags($_POST['content']);
-
$sql1 = "insert into message values(NULL, '" . $mysql->escape($email) . "' ,'".$mysql->escape($content)."')";
-
$mysql->runSql( $sql1 );
-
-
-
$sql = "SELECT * FROM `message` order by id desc LIMIT 10";
-
$data = $mysql->getData($sql);
-
$responseText = "
";
-
-
foreach($data as $message){
-
$onemessage = "
-
-
Email: |
-
".$message['email']." |
-
-
-
Content: |
-
".$message['content']." |
-
";
-
$responseText = $responseText.$onemessage;
-
}
-
$responseText = $responseText."
";
-
echo $responseText;
-
-
-
?>
阅读(1087) | 评论(1) | 转发(0) |