ASP產生靜態網頁,學習CASE的用法,以及“許可權”的一種控制方法

來源:互聯網
上載者:User
靜態|控制|網頁 <form action="calscore.asp?action=do" method="post" name=form1> ... </form>


<!--#include file="connect.asp"-->
<% if session("logstatus")<>1 then %>
<p align="center">
<font size="5" ><b>你還沒有登入,沒有權利瀏覽本頁,請先<a href="login.asp">登入</a>!</b></font></p>
<%
else
'讀取login.htm附帶的SubjectNo、StudentID及Name參數值
Subject=Request("Subject")
StudentID=Request("StudentID")
Name=Request("Name")

******** 路徑和檔案的建立 ********************************************************************
'格式化日期
Function format(date)
format=datepart("yyyy",date)&"年"&datepart("m",date)&"月"&datepart("d",date)&"日 "&formatdatetime(date,vbshorttime)
End Function
dim fmonth,fday,fhour,fminute,fsecond
fmonth=month(date)
if len(month(date))<2 then fmonth="0"&month(date) end if
fday=day(date)
if len(day(date))<2 then fday="0"&day(date) end if
fhour=hour(now())
if len(hour(now()))<2 then fhour="0"&hour(now()) end if
fminute=minute(now())
if len(minute(now()))<2 then fminute="0"&minute(now()) end if
fsecond=second(now())
if len(second(now()))<2 then fsecond="0"&second(now()) end if
newspath=year(date)&fmonth&fday
newsurl=fhour&fminute&fsecond
putdate=format(now())

if request("action")="do" then

path=server.MapPath("kaoshi") /.定義的一個檔案
set fso=server.CreateObject("Scripting.FileSystemObject")
if fso.FolderExists(path)=false then
fso.CreateFolder(path)
end if
path=path&"/"&newspath
if fso.FolderExists(path)=false then
fso.CreateFolder(path)
end if
path=path&"/"&newsurl&".shtml" /.產生SHTML頁面

set ts=fso.OpenTextFile(path,2,true,-2)

******** 產生HTML頁面 ***********************************************************************
ts.writeline"<html>"
ts.writeline"<head>"
ts.writeline"<title>"&name&""
ts.writeline","&subject&""
ts.writeline" - 成績結果</title>"
ts.writeline"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
ts.writeline"<link rel=""stylesheet"" href=""css.css"" type=""text/css"">"
ts.writeline"</head>"
ts.writeline""

ts.writeline"<body bgcolor=""#FFFFFF"" text=""#000000"">"
ts.writeline"<table width=""100%"">"
ts.writeline"<tr>"
ts.writeline"<td width=""100%"">"
ts.writeline"<h2>"
ts.writeline""&Name&""
ts.writeline",你的考試成績如下表:</h2>"

dim score
score=0
sqlt="select * from 考題類型"
rst.open sqlt,conn,1,1
do while not rst.eof
tn=rst("id")
tname=rst("name")

ts.writeline"<b>"
ts.writeline""&tname&""
ts.writeline"</b><br><br>"

sql="Select * From "&Subject&" where 題目類型="&tn&" order by 題目序號"
rs.open sql,conn,2,2
while not rs.eof
answer=rs("正確答案")
select case rs("題目類型")
case 1:
selection=Request("No"&rs("題目序號"))
ts.writeline rs("題目序號")
ts.writeline"、"&selection&"<br>"
case 2:
selection=""
for n=1 to 4
if not Request("No"&rs("題目序號")&"-"&n)="" then
selection=selection&Request("No"&rs("題目序號")&"-"&n)
end if
next
ts.writeline rs("題目序號")
ts.writeline" 、"&selection&"<br>"
case 3:
selection=Request(rs("選擇項1"))
ts.writeline rs("題目序號")



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。