Developing an online examination program with ASP (IV.)

Source: Internet
Author: User
Tags query
program | Online 2000-09-08 · Compiling green Apple Computer Studio Yesky

Checkuser.asp
At the beginning of the application, after the visitors type their password, their details are pointed to a page, such as sendregister.asp, to examine the specific
User name and password are present in the database.
Sql_check = "SELECT count (*) from loginuser where username = '" & _
Username & "' and password = '" & UserEmail & ""
Set Rs_check = Application ("Conn"). Execute (Sql_check)
If Rs_check (0) < > 0 Then
Session ("username") = Request.Form ("username")
Response.Redirect "Default.asp"
End If
If Rs_check (0) = 0 Then
Session ("error") = "wrong USER NAME OR PASSWORD"
Response.Redirect "Index.asp"
End If
The SQL command checks to see if a particular user has been registered. If the return value is 0, the user name or email is invalid, and the user is booted back to the registration page.
If it is a member, it is directed to the Default.asp page. This time, the replacement function is used to ensure that if the member types ' (single quotes), use the '
(double quotes) to replace.
Username = replace (Request.Form ("username"), "'", "" "
UserEmail = replace (Request.Form ("password"), "'", "" "
Choose a Quiz
Default.asp
Once successfully logged in, a second interface appears, providing a list of quiz subjects that members can choose from. In this case, we have HTML and DHTML, and of course we can
To increase the number of topics by adding tables. Default.asp requires that the table be installed with a drop-down menu containing a list of topics. Query the database, from the table of the quiz paper
Two domains are collected in.
sql_papers = "Select *id, topic from paper sort order by topic ASC"
SET rs_papers = Application ("Conn"). Execute (Sql_papers)
To display the results in the Drop-down menu, use the following code:
Select Size=1 name=select1 onchange= "msec (document.form1._
Select1.options[document.form1.select1.selectedindex].value); ">
< option value= "0" >select the examination
<%do while not rs_papers. eof% >
< option value= "<%=rs_papers (" id ")% >" ><%=lcase (rs_papers ("topic"))% ></option >
<%
Rs_papers. MoveNext
Loop
% >
The msec function calls redirect.asp on the basis of the X value, and the value of the query string:? x as the value of the selected item in the Drop-down menu.
function msec (x)
{if (x==0)
{Alert ("Please select any one of the examinations")
}
Else
{location.href= "redirect.asp?section=" + X
}
}



Related Article

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.