ASP generates static Web pages, learning the usage of case, and a control method of "permission"

Source: Internet
Author: User
static | control | page <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> you have not logged in, do not have the right to browse this page, please first <a href= "login.asp" > Login </a>! </b></font></p>
<%
Else
' Read the Subjectno, StudentID, and name parameter values that came with the login.htm
Subject=request ("Subject")
Studentid=request ("StudentID")
Name=request ("Name")

Path and file creation ********************************************************************
' Format date
Function Format (date)
Format=datepart ("yyyy", date) & "year" &datepart ("M", date) & "Month" &datepart ("D", date) & "Day" & 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 (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")/. a file defined
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"/. Generate sHTML Page

Set TS=FSO. OpenTextFile (path,2,true,-2)

Generate HTML page ***********************************************************************
Ts.writeline "
Ts.writeline "
Ts.writeline "<title>" &name& ""
Ts.writeline "," &subject& ""
Ts.writeline "-Results </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 "
Ts.writeline ""

Ts.writeline "<body bgcolor=" "#FFFFFF" "text=" "#000000" ">"
Ts.writeline "<table width=" "100%" ">"
Ts.writeline "<tr>"
Ts.writeline "<td width=" "100%" ">"
Ts.writeline "
Ts.writeline "" &Name& ""
Ts.writeline ", your exam results are as follows:

Dim score
Score=0
sqlt= "SELECT * from Exam type"
Rst.open sqlt,conn,1,1
Do as 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 topic type =" &tn& "ORDER by topic serial number"
Rs.Open sql,conn,2,2
While not rs.eof
Answer=rs ("correct answer")
Select Case RS ("topic type")
Case 1:
Selection=request ("No" &rs ("title serial Number"))
Ts.writeline rs ("title serial Number")
Ts.writeline "," &selection& "<br>"
Case 2:
Selection= ""
For N=1 to 4
If not Request ("No" &rs ("title serial Number") & "&n" = "" Then
Selection=selection&request ("No" &rs ("title serial Number") & "-" &n)
End If
Next
Ts.writeline rs ("title serial Number")
Ts.writeline "," &selection& "<br>"
Case 3:
Selection=request (RS ("option 1"))
Ts.writeline rs ("title serial Number")



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.