addguest.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<title>写留言簿</title>
</head>
<body vlink="#008000" link="#0000FF" alink="#FF0000" background="INMTEXTB.GIF">
’留言簿标题
<p align="center"><big><big><font face="隶书" color="#FF0000"><strong>写
留 言 簿</strong></font></big></big></p>
’留言提示信息
<p align="left"> <strong><font color="#008080">We'd like to know what
you think about our web site. Please leave your comments in this public guest book so we
can share your thoughts with other visitors.</font></strong></p>
’留言表单
<form method="POST" action="gbook.asp"> ’表单内容将提交到gbook.asp进行处理
<p><font face="宋体" color="#008040"><strong>
您的名字: <input type="text" name="Name" size="21"><small>(不能空?lt;/small><br>
您的E-Mail: <input type="text" name="Email" size="35"><br>
您的主页URL: <input type="text" name="Url" size="40"><br>
您来自 国家: <input type="text" name="Country" size="16">
省份: <input type="text" name="State" size="10">
城市: <input type="text" name="City" size="10"></strong></font></p>
’留言内容
<p><font face="宋体" color="#008040"><strong>请把您的留言写在下面<small>(不能空)</small>:<br>
<textarea name="Comments" COLS="66" ROWS="11"></textarea></strong></font></p>
’留言之提交和清除按钮
<div align="left"><p> <font face="宋体"
color="#008040"><strong><input type="submit" value="提 交(Submit)" name="Submit"
style="font-family: 隶书; font-size: 10pt; color: rgb(0,0,255); font-weight: bold"><input
type="reset" value="清 除(Reset)" name="Reset"
style="font-family: 隶书; font-size: 10pt; color: rgb(0,0,255); font-weight: bold"></strong></font></p>
</div>
</form>
</body>
</html>
gbook.asp
’<% %>均为ASP语句
<%
’将数据中的单引号替换为双引号并在前后加上单引号
Function SqlStr( data )
SqlStr = "'" & Replace( data, "'", "''" ) & "'"
End Function
’ 利用Request对象从addguest.htm表单中取输入之留言信息
Name = Request("Name")
Email = Request("Email")
Url = Request("Url")
Country = Request("Country")
State = Request("State")
City = Request("City")
Comments = Request("Comments")
’ 判断姓名和内容是否为空,否则给出提示信息
If Name <> "" And Comments <> "" Then
’ 创建ADODB对象
Set conn = Server.CreateObject("ADODB.Connection")
’打开ODBC数据源guestbook
conn.Open "guestbook","",""
’对信息按数据库中字段定义长度进行处理,因插入数据时其值不能为空,故由空格表示
Name = Left( Name, 10 )
if email="" then
Email=" "
else
Email = Left( Email, 40 )
end if
if Url="" then
Url=" "
else
Url = Left( Url, 50 )
end if
if Country="" then
Country=" "
else
Country = Left( Country,10)
end if
if State="" then
State=" "
else
State = Left( State,10)
end if
if City="" then
City=" "
else
City = Left( City,10)
end if
’定义SQL语句,将信息加入数据库中
sql = "Insert Into Guestbook (Name, Email, Url, Country,State,City,Comments) Values( "
sql = sql & SqlStr(Name) & ", "
sql = sql & SqlStr(Email) & ", "
sql = sql & SqlStr(Url) & ", "
sql = sql & SqlStr(Country) & ", "
sql = sql & SqlStr(State) & ", "
sql = sql & SqlStr(City) & ", "
sql = sql & SqlStr(Comments) & ")"
’执行SQL语句
conn.Execute sql
’自动转至查看留言薄页面
Response.Redirect "guestbook.asp"
end if
%>
<html>
<head>
<title>留言处理</title>
</head>
<body background="INMTEXTB.GIF">
<p></p>
’ 如果姓名和内容为空,给出提示信息
<p align="center"> <big> <font color="#FF0000" face="仿宋_GB2312"><strong>姓名和留言必须输入!</strong></font></big></p>
<p align="center"><strong><font face="隶书"><a href="addguest.htm">返 回</a></font></strong></p>
转贴于 酷文网-论文下载中心 http://www.coolwen.net
共8页: 上一页 [1] [2] [3] [4] [5] 6 [7] [8] 下一页
网摘收藏: