php留言板

/************/config.php/***********/?php $host =
‘localhost’; // 数据库服务器 $user = ‘root’; // 数据库用户名 $password =
‘123456’; // 数据库密码 $db = ‘project’; // 数据库名

//打开数据库$conn = mysql_pconnect
($host,$user,$password);if(!$db){die(‘b数据库连接失败!/b’);}//选择数据库mysql_select_db
($db);?/*********************/index.php/********************/

htmlbodyscript type=text/javascriptfunction check_form(obj){
if(document.getElementById(‘post_name’).value==”){
alert(‘写一下您的大名吧’);
document.getElementById(‘post_name’).focus(); return false; }
if(document.getElementById(‘post_body’).value==”){
alert(‘不是来捣乱的吧,写一下留言内容吧!’);
document.getElementById(‘post_body’).focus(); return false; } return
true;

}/script form action=/sent.php method=post onSubmit=return
check_澳门新葡亰手机版,form(this) table width=100% border=0 tr td align=right您的大名/td
tdinput name=post_name id=post_name type=text size=20 maxlength=20/td
/tr td align=right您的发言/tdtdtextarea name=post_body id=post_body
rows=10 cols=50您的发言/textarea/td tr td align=right /td tdinput
type=submit name=Submit value=提 交 /td /tr /table /form/td /body
html?php
include(‘get.php’)?/***************************/get.php/****************************/[quote]?phpinclude(‘config.php’);$query
= SELECT * FROM project_post;$result = mysql_query($query);

while($row = mysql_fetch_array($result)) echo 姓名:$row[post_name]
/br 内容:
$row[post_body]/br;?/***************************/sent.php/***************************/

?phpinclude(‘config.php’);$post_name=addslashes($_POST[‘post_name’]);$post_body=addslashes($_POST[‘post_body’]);$sql
= INSERT INTO project_post (post_name,post_body)
VALUES(‘$post_name’,’$post_body’);mysql_query($sql);header(‘location:/index.php’);?