Developing an online examination program with ASP (III.)

Source: Internet
Author: User
program | Online sendregister.asp
This page gets the contents of the form fields from the register.asp and inserts them into the database. Note that the username must be unique. So, first query to
Verify that the user name you entered already exists. If so, the user is register.asp back to the page and is asked to select another user name. If the user
The name is new and the input is passed to the database.
Sql_findmember = "SELECT count (*) from loginuser where username = '" & Username & "'"
Set rs_findmember = Application ("Conn"). Execute (Sql_findmember)
If rs_findmember (0) < > 0 Then
Session ("message") = "The ENTRY HAD BEEN INSERTED earlier ... "Try another log in name"
Response.Redirect "Register.asp"
End If
If rs_findmember (0) = 0 Then
Sql_insert = "INSERT into Loginuser (Username,useremail,password) _
VALUES (' & username & ', ' "& UserEmail &", ' "& pwd &") "
Set Rs_insert = Application ("Conn"). Execute (Sql_insert)
Session ("message") = "The ENTRY has BEEN INSERTED ... Thank You "
Response.Redirect "Index.asp"
End If
Thus, if Rs_findmember (0) Returns a value of 0, it means that the username does not exist in the database and the name is entered. Members will be able to use the station
The other part of the point. Conversely, if Rs_findmember (0) returns a value greater than 0, the user is booted back to the registered home page and is required to fill out a new user
Name.
Also note that there are some things to be wary of before inserting data into the database. The substitution function is used to make sure that when a visitor types "', you need to use the ' generation '
For.
Username = replace (Request.Form ("Txt_name"), "'", "" "



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.