?? saveedit.asp
字號:
<%@ Language=VBScript %>
<!--#INCLUDE FILE="conn.asp" -->
<%
FUNCTION txtToURL(tekst)
Tekst_temp = tekst
Tekst_temp = Replace(Tekst_temp,"<","<")
Tekst_temp = Replace(Tekst_temp,">",">")
txtToURL = Tekst_temp
END FUNCTION
'--------------------讀取數據------------------------------------
name=request("name")
from=request("from")
subject=request("subject")
email=request("email")
homepage=request("homepage")
hits=request("hits")
retimes=request("retimes")
oicq=request("oicq")
sex=request("sex")
note=request("note")
if from="" then from="遠方的城市"
if oicq="" then oicq="000000"
if hits="" then hits="0"
if retimes="" then retimes="0"
if homepage="" or homepage="http://" then homepage="還沒有!"
'------------------------------------------------------------
if trim(subject)="" then '-------------------------判斷標題
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('請填入標題!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
'------------------------------------------------------------
if trim(name)="" then '--------------判斷名字
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('請填入你的名字');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
'------------------------------------------------------------
if trim(oicq)<>"" then '--------------判斷OICQ
if not(isnumeric(oicq)) then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('"&name&", OICQ必須是數字.');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
if len(oicq)<5 or len(oicq)>9 then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('OICQ號碼必須大于5小于9位!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
end if
'--------------------判斷email函數----------
If email<>"" and IsValidEmail(email)=false then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('信箱地址錯誤!');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
'----------------------------------------------
if trim(note)="" then '--------------判斷內容
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('怎么可以沒內容呢?');" & VbCrlf
response.write "history.go(-1);" & vbCrlf
response.write "</script>" & VbCRLF
response.end
end if
'-------------------------------------------------
function IsValidEmail(email)'判斷-------------------------
dim names, name, i, c
IsValidEmail = true
names = Split(email, "@") '-----------判斷有否@-------------------
if UBound(names) <> 1 then '---------無---------
IsValidEmail = false
exit function
end if
for each name in names '分割的每段長度-----------------
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1)) '------------分割成每個字母或數字------------------
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then '---------------------
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".") '---------------------------
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function '------------------------函數結束
'----------------------------------------------------------------
Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from book where id="&request("id")
rs.open sql,conn,3,2
rs.update
rs("n")=Server.HtmlEncode(name)
rs("f")=Server.HtmlEncode(from)
rs("e")=email
rs("hits")=hits
rs("retimes")=retimes
rs("subject")=subject
rs("h")=homepage
rs("q")=Server.HtmlEncode(oicq)
rs("note")=txttourl(note)
rs("s")=sex
rs.update
rs.close
response.redirect "default.asp"
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -