⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 save.asp

📁 基于asp的 班级同学录主页源代码
💻 ASP
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<!--#include file="bkconn.asp"-->
<%if session("user")="" then
response.redirect "../err.asp"
end if%>
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"&lt;"
case ">"
result=result+"&gt;"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"&quot;"
case "&"
result=result+"&amp;"
case chr(32)	
'result=result+"&nbsp;"
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9)  then	
result=result+"&nbsp;"
else
result=result+" "
end if
else
result=result+"&nbsp;"	
end if
case chr(9)
result=result+"    "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function


sub chkInput()
if Trim(sTitle)="" then
sTitle="<大家>"
elseif len(sTitle)>50 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “对方昵称” 的 长 度 不 能 大 于 50 !"
end if
if Trim(sInput)="" then
foundError=true
ErrorMsg=ErrorMsg+"没 有 留 言 , 请 留 下 您 的 宝 贵 意 见 !"
elseif len(sInput)>2000 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “留 言” 的 长 度 不 能 大 于 2000 (2K)!"
end if
end sub

sub getInput()
sName=trim(request.form("txtName"))
sEmail=trim(request.form("txtEmail"))
sHomePage=trim(request.form("txtHomePage"))
sFace=trim(request.form("face"))
sTitle=trim(request.form("txtTitle"))
sInput=trim(request.form("txtContent"))
end sub
%>
<%
dim sql
dim rs

dim sName
dim sEmail
dim sTitle
dim sFace
dim sHomePage
dim sInput

dim foundError
dim errorMsg

getInput()
chkInput()


if foundError then
call showErrors()
else

saveData()
if foundError then
call showErrors()
end if
end if
set rs=nothing%>

<!--#include file="conn.asp"-->
<%
connuser.execute "update user set usermoney=usermoney+1 where user='"&session("user")&"'"
connuser.close
set connuser=nothing
call success()
%>

<%   sub saveData()
on error resume next
dim cmdTemp
dim InsertCursor
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT * FROM book where name is null"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = conn
InsertCursor.Open cmdTemp, , 1, 3
InsertCursor.addnew
InsertCursor("name") =htmlencode2(sName)
InsertCursor("face") =sFace&".gif"
InsertCursor("title") =htmlencode2(sTitle)
InsertCursor("content") =htmlencode2(sInput)
InsertCursor("time") =cstr(now())
InsertCursor.Update
InsertCursor.close
conn.close
set InsertCursor=nothing
set conn=nothing
if err>0 then
err.clear
foundError=true
ErrorMsg="<li>数 据 库 操 作 失 败 !</li>"
end if
end sub

sub showErrors()
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style.css">
<title>输 入 有 错 </title>
</head>

<body bgcolor="6699cc">
<p><strong><font color="#FFFFFF">不 能 保 存 留 言 !</font></strong>
<ul>
<font color="#0080FF"><%=ErrorMsg%>
</font>
</ul>
<div align="center">
<form name="frmgstbook" action="save.asp" method="post" >
<table width="468" border="1" cellspacing="0" cellpadding="2" height="306" bgcolor="#E1FFE1" bordercolordark="#FFFFFF" bordercolorlight="#000000">
<tr align="right">
<td colspan="5">请 留 言<font size="2">....................<a href="display.asp">观看留言</a></font></td>
</tr>
<input type="text" name="txtname" size="20" value="<%=session("user")%>">
<tr>
<td width="84" align="right" height="27">对方昵称:</td>
<td colspan="4" height="27" width="345">
<input type="text" name="txttitle" size="20">
</td>
</tr>
<tr>
<td width="84" align="right">您的表情:</td>
<td colspan="4" width="345">
<input type="radio" value="1"
name="face" checked>
<img src="IMAGES/1.gif" >
<input
type="radio" value="2" name="face">
<img src="IMAGES/2.gif" >
<input
type="radio" value="3" name="face">
<img src="IMAGES/3.gif" >
<input type="radio" value="4" name="face">
<img src="IMAGES/4.gif" >
<input type="radio" value="5" name="face">
<img src="IMAGES/5.gif" >
<input type="radio" value="6" name="face">
<img src="IMAGES/6.gif" > <br>
<input type="radio" value="10" name="face">
<img src="IMAGES/10.gif">
<input type="radio" name="face" value="11">
<img src="IMAGES/11.gif">
<input type="radio" name="face" value="12">
<img src="IMAGES/12.gif">
<input type="radio" name="face" value="13">
<img src="IMAGES/13.gif">
<input type="radio" name="face" value="14">
<img src="IMAGES/14.gif" >
<input type="radio" name="face" value="15">
<img src="IMAGES/15.gif" > <br>
<input type="radio" name="face" value="16">
<img src="IMAGES/16.gif">
<input type="radio" name="face" value="17">  <img src="IMAGES/17.gif" >
<input type="radio" name="face" value="18">
<img src="IMAGES/18.gif" >
<input type="radio" value="7" name="face">
<img src="IMAGES/7.gif" >
<input type="radio" name="face" value="8">
<img src="IMAGES/8.gif" >
<input type="radio" name="face" value="9">
<img src="IMAGES/9.gif" > </td>
</tr>
<tr>
<td width="84" height="74" align="right">留言:</td>
<td colspan="4" height="74" valign="top" width="345"><font color="#000000">
<textarea
cols="50" name="txtContent" rows="9"></textarea>
</font></td>
</tr>
</table>
<p>
<input class="button" type="submit" name="cmdok" value="写完了">
<input class="button" type="reset" name="cmdreset" value="重写">
</p>
</form>
</div>
<h5>&nbsp;</h5>
</body>
</html>
<%end sub%>
<%
sub success()
Response.Redirect ("index.asp")
end sub
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -