?? addform.asp
字號(hào):
<%
'這是安全模塊,如果客戶不是管理員用戶,立即重定向到首頁.
'這樣可以防止某些客戶直接訪問admin下面的文件。
If Session("usertype")<>"A" Then
Response.Redirect "../index.asp"
End If
%>
<!--#INCLUDE FILE="../odbc_connection2.asp"-->
<html>
<head>
<title>增加成員</title>
<script language="JAVASCRIPT">
function check_Null(){
if (document.form1.name.value==""){
alert("名稱不能為空!");
return false;
}
if (document.form1.URL.value==""){
alert("地址不能為空!");
return false;
}
return true;
}
</script>
</head>
<body>
<h2 align="center">添加成員</h2>
<center>
<form method="post" action="" name="form1" onsubmit="javascript: return check_Null();">
<table border="0" width="90%" >
<tr>
<td>網(wǎng)站名稱:</td><td><input type="text" name="name" size="20">**(帶**的內(nèi)容必須輸入)</td>
</tr><tr>
<td>網(wǎng)站地址:</td><td>http://<input type="text" name="URL" size="20">**</td>
</tr><tr>
<td>網(wǎng)站評(píng)分:</td>
<td>
<select name="grade">
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected>3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
</tr><tr>
<td>網(wǎng)站簡(jiǎn)介:</td><td><textarea name="intro" rows="3" cols="50" wrap="soft"></textarea></td>
</tr>
<table>
<p align="center"><input type="submit" value=" 確 定 ">
</form>
</center>
<%
'這個(gè)程序使用了客戶端驗(yàn)證,所以只有填寫了名稱和地址才能提交表單。
'下面這個(gè)判斷的主要作用是防止第一次打開頁面時(shí)立即執(zhí)行其中的語句。它可以確保只有提交表單后才會(huì)執(zhí)行其中的語句。
If Request.Form("name")<>"" Then
'下面定義4個(gè)變量,用來獲取表單中的值
Dim name,URL,intro,grade
name=Request.Form("name")
URL=Request.Form("URL")
intro=request.Form("intro")
grade=request.Form("grade")
'下面組織Insert語句,先將其分為前后兩部分,分別完成
Dim sqla,sqlb,strSql
sqla = "Insert into link(name,URL,submit_date,grade"
sqlb = " Values('" & name & "','" & URL & "',#" & Now() & "#," & grade
If intro<>"" Then
sqla = sqla & ",intro"
sqlb = sqlb & ",'" & intro & "'"
End If
'最后將前后兩部分組合成一個(gè)完整的Insert語句
strSql = sqla & ") " & sqlb & ")"
'下面執(zhí)行添加記錄的操作
db.Execute(strSql)
'添加記錄后返回首頁,但是希望返回首頁后立即能看到剛添加的記錄,所以需要設(shè)置有關(guān)變量
Session("keyword")=""
Session("field")="name"
Session("sortfield")="submit_date Desc"
Session("page_no")=1
Response.redirect "wwwadmin.asp"
End If
%>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -