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

📄 savedata.asp

📁 一套很早的多用户电子商务程序
💻 ASP
字号:
<!--#include file="bkconn.asp"-->
<!--#include file="inc/chkStr.inc"-->
<!--#include file="inc/char.inc"-->
<%
   dim sql
   dim rs
   dim sName
   dim sEmail
   dim sSex
   dim sFrom 
   dim sHomePage
   dim sConTop
   dim sInput
   dim foundError
   dim errorMsg
   call getInput()
   call chkInput()

   if foundError then
      call showErrors()
   else
      saveData()
      if foundError then
         call showErrors()
      else
          response.redirect "book.asp"
      end if
   end if
   set rs=nothing  
   conn.close
   set conn=nothing

   

   sub saveData()
       on error resume next
       dim cmdTemp
       dim InsertCursor
       dim dataconn
       Set DataConn = Server.CreateObject("ADODB.Connection")
       dataconn.open connstr
       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 = dataconn
       InsertCursor.Open cmdTemp, , 1, 3
       InsertCursor.addnew 
       InsertCursor("name") =sName
       InsertCursor("sex") =sSex
       InsertCursor("fromwhere") =sFrom
       InsertCursor("homepage") =sHomePage
       InsertCursor("email") =sEmail
       InsertCursor("contenttop") =sConTop
       InsertCursor("content") =sInput
       InsertCursor("dateandtime") =cstr(year(now()))+"-"+cstr(month(now()))+"-"+cstr(day(now()))+"  " & cstr(time())
       InsertCursor.Update
       InsertCursor.close
       dataconn.close
       set InsertCursor=nothing
       set dataconn=nothing
       if err>0 then 
          err.clear
          foundError=true
          ErrorMsg="<li>服务器数据库操作失败!</li>"
       end if
   end sub

   sub chkInput()
   if sName="" then
       foundError=true
       ErrorMsg=ErrorMsg+"<br>●“大名”字段不能为空白!"
   else
       if Len(sName)>=50 then
          foundError=true
          ErrorMsg=ErrorMsg+"<br>●“大名”字段长度不能大于50 !" 
       end if
   end if
   if sConTop="" and sInput="" then
      foundError=true
      ErrorMsg=ErrorMsg+"<br>●“主题”或“留言”字段不能同时为空白!"
   else
      if Len(sContop)>=255 then
          foundError=true
          ErrorMsg=ErrorMsg+"<br>●“主题”字段长度不能大于255 !"
      else
          if Len(sInput)>=16384 then
             foundError=true
             ErrorMsg=ErrorMsg+"<br>●“留言”长度不能大于16384(16K)!"
          end if
      end if
   end if
   if Len(sEmail)>=255 then
      foundError=true
      ErrorMsg=ErrorMsg+"<br>●“邮箱”字段长度不能大于 255 !"
   end if
   if Len(sFrom)>=50 then
      foundError=true
      ErrorMsg=ErrorMsg+"<br>●“来自”字段长度不能大于50 !"
   end if
   if Len(sHomePage)>=255 then
      foundError=true
      ErrorMsg=ErrorMsg+"<br>●“主页”字段长度不能大于255 !"
   end if
   end sub

   sub getInput()
       if iis3onchsys=true then
          sName=HTMLCharacter(request("txtName"))&""
          sEmail=HTMLCharacter(request("txtEmail"))&""
          sSex=HTMLCharacter(request("selSex"))&""
          sFrom=HTMLCharacter(request("txtFrom"))&""
          sHomePage=HTMLCharacter(request("txtHomePage"))&""
          sConTop=HTMLCharacter(request("txtConTop"))&""
          sInput=HTMLCharacter(request("txtContent"))&""
     else
          sName=replace(request("txtName"),"<","〈")&""
          sEmail=replace(request("txtEmail"),"<","〈")&""
          sSex=replace(request("selSex"),"<","〈")&""
          sFrom=replace(request("txtFrom"),"<","〈")&""
          sHomePage=replace(request("txtHomePage"),"<","〈")&""
          sConTop=replace(request("txtConTop"),"<","〈")&""
          sInput=replace(request("txtContent"),"<","〈")&""
     end if
   end sub

   sub showErrors()
%>
<html>

<head>
<style type="text/css">
<!-
td{font-size:12px;}
body{font-size:12px;line-height:17px;}
a:link{text-decoration:none;color:#008040}
a:visited{text-decoration:none;color:#008040}
a:active{text-decoration:none}
a:hover {  color:#FF8040; text-decoration: underline}
->
</style>
<title>发现输入错误</title>
</head>

<body background="002.gif">

<p align="center"><img src="guestbook.gif" WIDTH="283" HEIGHT="60"></p>

<p><span style="font-size: 9pt"><font color="#FF0000">发现输入过程中有错误,请按下列提示检查:<br>
</font><font color="#0080FF"><%=ErrorMsg%></span> </font></p>
<form method="POST" action="saveData.asp" name="frmGstBook">
  <div align="center"><center><table border="1" cellpadding="3" bgcolor="#F8DC9C" width="195" cellspacing="1" bordercolor="#FFFFFF" bordercolordark="#FFFFFF" bordercolorlight="#C0C0C0">
    <tr align="center">
      <td nowrap width="505" height="7" align="right" colspan="4"><div align="center"><center><p><font size="3" color="#008000">&nbsp; 请 您 留 言</font></td>
    </tr>
    <tr align="center">
      <td nowrap width="72" height="6" align="right"><div align="right"><p>大名:</td>
      <td nowrap height="6" align="center" width="182"><div align="left"><p><input class="smallInput" type="text" name="txtName" size="28" style="font-family: aa; font-size: 9pt"  value="<%=htmlencode2(sName)%>"></td>
      <td width="59" height="6" align="right" nowrap>性别:</td>
      <td height="6" align="center" width="203" nowrap><div align="left"><p><select class="smallSel" name="selSex" size="1" style="font-size: 9pt">
        <option value="女士">女士</option>
        <option selected value="先生">先生</option>
        <option value="不想说">不想说</option>
      </select></td>
    </tr>
    <tr align="center">
      <td nowrap width="72" height="12" align="right"><div align="right"><p>来自:</td>
      <td nowrap height="12" align="center" width="182"><div align="left"><p><input class="smallInput" type="text" name="txtFrom" size="28" style="font-family: aa; font-size: 9pt" value="<%=htmlencode2(sFrom)%>"></td>
      <td width="59" height="12" align="right" nowrap><div align="right"><p>邮箱:</td>
      <td height="12" align="center" width="203" nowrap><div align="left"><p><input class="smallInput" type="text" name="txtEmail" size="26" style="font-size: 9pt"  value="<%=htmlencode2(sEmail)%>"></td>
    </tr>
    <tr align="center">
      <td nowrap width="72" height="25" align="right"><div align="right"><p>主页:</td>
      <td colspan="3" nowrap width="201" height="25" align="center"><div align="left"><p><input class="smallInput" type="text" name="txtHomePage" size="67" value="http://" style="font-size: 9pt"  value="<%=htmlencode2(sHomePage)%>"></td>
    </tr>
    <tr align="center">
      <td nowrap width="72" height="25" align="right"><div align="right"><p>主题:</td>
      <td colspan="3" nowrap width="201" height="25" align="center"><div align="left"><p><input class="smallInput" type="text" name="txtConTop" size="67" style="font-size: 9pt" value="<%=htmlencode2(sConTop)%>"></td>
    </tr>
    <tr align="center">
      <td nowrap width="72" align="center" height="167"><div align="right"><p>留言:</td>
      <td colspan="3" nowrap width="201" align="center" height="167"><div align="left"><p><textarea rows="8" class="smallArea" name="txtContent" cols="66" style="font-size: 9pt"><%=htmlencode2(sInput)%></textarea></td>
    </tr>
  </table>
  </center></div><div align="center"><center><p>&nbsp; <input type="submit" value="保存留言" name="cmdOk" style="font-size: 9pt">&nbsp; <input type="reset" value="清空留言" name="cmdReset" style="font-size: 9pt">&nbsp; <input type="button" value="放弃留言" name="cmdExit" style="font-size: 9pt" OnClick=" history.back()"></p>
  </center></div>
</form>
</body>
</html>
<%end sub%>

⌨️ 快捷键说明

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