; echo"对不起!请先<a href=register.html>注册</a>!";
}
else{
//得到日期 YYYY-MM-DD HH:MM:SS 2000-01-01 00:00:00'
$t = date(Y."-".m."-".d." ".H.":".i.":".s);
//将新用户插入数据库
mysql_query("insert into message values ('$username','$email','$homepage','$topic','$content','$t')");
echo "<div align=center><font size=2 color=#000000>谢谢您留言!您的留言已成功加入,<a href=guestbook.php>返回</a></font></div>";
}
}
?>
3.zhuc.php(注册程序)
<?
mysql_connect("localhost","root","")
or die("无法连接数据库,请重试");
mysql_select_db("lyanban")
or die("无法选择数据库,请重试");
$query="select password from tb where username='$username'";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows!=0)
{echo '已有人注册此名,请重新选择名字!<a href=javascript:history.go(-1);>返回</a>';}
else
{$query="insert into tb(username,password) values('$username','$password')";
mysql_query($query);
echo '注册成功';
echo '<A HREF="guestbook.htm" >请登录!</A>';}
?>
以下是两个配套的HTML:
1。留言网页
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>天地网络留言版欢迎您留言!</title>
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<center>
<br>
<font size="2">天地网络留言版测试版</font><br>
<br>
<form method="post" action="show.php3">
<table width="66%">
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2"> 您的尊姓大名:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="name" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"><font size="2"> 您的电子邮件地址:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="email" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"><font size="2"> 您的公司主页地址:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="homepage" size="20" value="http://">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2">留言主题:</font></div>
</td>
<td width="50%" height="1" valign="middle">
<div align="center">
<input type="text" name="topic" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2">留言内容:</font></div>
</td>
<td width="50%" height="1">
<div align="center"> </div>
</td>
</tr>
<tr>
<td width="100%" colspan="2" height="66">
<p align="center">
<textarea rows="10" name="content" cols="50"></textarea>
</p>
</td>
</tr>
<tr>
<td width="50%" height="18">
<div align="center"></div>
</td>
<td width="50%" height="18">
<div align="center"></div>
</td>
</tr>
<tr>
<td width="50%" height="18" align="center">
<p align="center">
<input type="submit" value="发表留言" name="B1">
</p>
</td>
<td width="50%" height="18" align="center">
<div align="center">
}
else{
//得到日期 YYYY-MM-DD HH:MM:SS 2000-01-01 00:00:00'
$t = date(Y."-".m."-".d." ".H.":".i.":".s);
//将新用户插入数据库
mysql_query("insert into message values ('$username','$email','$homepage','$topic','$content','$t')");
echo "<div align=center><font size=2 color=#000000>谢谢您留言!您的留言已成功加入,<a href=guestbook.php>返回</a></font></div>";
}
}
?>
3.zhuc.php(注册程序)
<?
mysql_connect("localhost","root","")
or die("无法连接数据库,请重试");
mysql_select_db("lyanban")
or die("无法选择数据库,请重试");
$query="select password from tb where username='$username'";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows!=0)
{echo '已有人注册此名,请重新选择名字!<a href=javascript:history.go(-1);>返回</a>';}
else
{$query="insert into tb(username,password) values('$username','$password')";
mysql_query($query);
echo '注册成功';
echo '<A HREF="guestbook.htm" >请登录!</A>';}
?>
以下是两个配套的HTML:
1。留言网页
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>天地网络留言版欢迎您留言!</title>
</head>
<body bgcolor="#FFFFFF">
<div align="center">
<center>
<br>
<font size="2">天地网络留言版测试版</font><br>
<br>
<form method="post" action="show.php3">
<table width="66%">
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2"> 您的尊姓大名:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="name" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"><font size="2"> 您的电子邮件地址:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="email" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"><font size="2"> 您的公司主页地址:</font></div>
</td>
<td width="50%" height="1">
<div align="center">
<input type="text" name="homepage" size="20" value="http://">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2">留言主题:</font></div>
</td>
<td width="50%" height="1" valign="middle">
<div align="center">
<input type="text" name="topic" size="20">
</div>
</td>
</tr>
<tr>
<td width="50%" height="1">
<div align="center"> <font size="2">留言内容:</font></div>
</td>
<td width="50%" height="1">
<div align="center"> </div>
</td>
</tr>
<tr>
<td width="100%" colspan="2" height="66">
<p align="center">
<textarea rows="10" name="content" cols="50"></textarea>
</p>
</td>
</tr>
<tr>
<td width="50%" height="18">
<div align="center"></div>
</td>
<td width="50%" height="18">
<div align="center"></div>
</td>
</tr>
<tr>
<td width="50%" height="18" align="center">
<p align="center">
<input type="submit" value="发表留言" name="B1">
</p>
</td>
<td width="50%" height="18" align="center">
<div align="center">