use test;
create table user (
id int(4) not null auto_increment,
title varchar(100),
name varchar(20),
content varchar(1000),
primary key(id));
<html>
<head><title>welcome</title></head>
<body>
<form action="send.php">
标题:<input type="text" name="title" size=20><br>
发表人:<input type="text" name="name" size=20><br>
内容: <textarea name="content" cols=80 rows=15></textarea><br>
<input type="submit" value="发送">
<input type="reset" value="重写">
</body>
</html>
<?php
$conn=mysql_connect("localhost","
or die("不能连接数据库服务器:".mysql_error());
mysql_select_db("test",$conn) or die("不能选择数据库".mysql_error());
?>
<?php
require("head.php");
$insertsql="insert into user(title,name,content) values('$title','$name','$content')";
$insert=mysql_query($insertsql,$conn);
if($insert){header("location:show.php");}
else{echo "失败"; exit;}
?>
<?php
require("head.php");
$result=mysql_query("select *from user",$conn);
while($row=mysql_fetch_row($result))
{
print "第".$row[0]."篇";echo"<br>";
print "标题:".$row[1];echo"<br>";
print "姓名:".$row[2];echo"<br>";
print "内容:".$row[3];echo"<br>";
}
echo"<br>";
?>
分析一下,首先在MYSQL中建立一个数据库,名字叫text,在text数据库里面建立一张表,叫user。然后再用记事本建立一个网页叫gbook.htm,里面有表格,然后由访客填写,通过发送,把数据送到了send.php文件中处理,然后存进了数据库。要使用程序的时候,把数据从数据库中读取出来,显示在屏幕上。