The article provides a simple ASP user login code, provided from the database tutorial to connect to the file login and user input information when JS judge verification ha.
<%
' Dim databasename,conn,constr
Databasename= "Userman.mdb"
Constr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DatabaseName)
Set Conn=server.createobject ("Adodb.connection")
Conn.Open Constr
%>
Login Paging File
<title> Please enter your username and password </title>
<body>
<script language = "VBScript" >
function Chkfields ()
Name = Document.myform.username.value
If Document.myform.username.value = "" Then
Window.alert ("Please enter your username!") ")
return False
End If
If Document.myform.userpwd.value = "" Then
Window.alert ("Please enter the password!") ")
return False
End If
If Document.myform.email.value = "" Then
Window.alert ("Please enter an email!") ")
return False
End If
return True
End Function
</script>
<p align = "center" ><font color= "#0000ff" size= "5" > User registration </font></p>
<p align = "center" ><font color = "#800000" >
</font></p>
<form method = "POST" action = "verify.asp" name = "MyForm" >
<center>
<table border= "0" width= "78%" >
<tr>
<TD width= "27%" bgcolor= "#c0c0c0" align= "center" ><font size= "2" > Username:</font></td>
<TD width= "73%" ><input type = "text" name = "username" size = 20> <font size= "2" color= "#ff0000" &G t;* User name can only enter uppercase or lowercase letters </font></td>
</tr>
<tr>
<TD width= "27%" bgcolor= "#c0c0c0" align= "center" ><font size= "2" > Password:</font></td>
<TD width= "73%" ><input type = "password" name = "userpwd" size = 20> <font size= "2" color= #ff0000 ">* password can only be entered in digital </font></td>
</tr>
<tr>
<TD width= "27%" bgcolor= "#c0c0c0" align= "center" ><font size= "2" > E-mail:</font></td>
<TD width= "73%" ><input type = "text" name = "email" size = 20> <font size= "2" color= "#ff0000" >* </font><font size= "2" color= "#ff0000" > Please fill in the correct message format </font></td>
</tr>
</table>
<p align = "center" ><input type = "submit" value = "commit" name = "B1" onclick = chkfields>
<input type = "reset" value = "reset" name = "B2" ></p>
</form>
<p align = "center" ></p>
</body>
Log in to process files
<%
' Read the identity data passed from the table conveys.
Username=trim (Request.Form ("username"))
Userpwd=request.form ("Userpwd")
Email=request.form ("email")
If username= "or userpwd=" "or email=" "then
response.write" <script>alert (' Fill incomplete! '); History.back ();</script> "
response.end
ElseIf not checkletter (username) then
Response.Write "<script>alert (' entered username is not all uppercase or lowercase letters!") '); History.back ();</script> "
response.end
ElseIf not IsNumeric (userpwd) then
Response.Write "<script>alert (' Enter the password is not a number!") '); History.back ();</script> "
response.end
ElseIf not isvalidemail (email) then
Response.Write "<script>alert (' Input email address format is not correct!) '); History.back ();</script> "
response.end
ElseIf len (username)" <6 then
Response.Write "<script>alert (' username is at least 6 bits long!") '); History.back ();</script> "
response.end
Else
response.write" <center> input is correct! "
End If
function Checkletter (str)
Checkletter=true
Letters= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
For I=1 to Len (str)
Checkchar=ucase (Mid (str,i,1)) returns the first character of the string Str and converts it to uppercase
if (InStr (Letters,checkchar) <=0) Then ' Checkchar the corresponding character does not exist in letters
Checkletter=false
Exit function
End If
Next
End Function
function IsValidEmail (email)
Dim names,name,i,c
Isvalidemail=true
Names=split (email, "@") ' uses the @ character to divide the email string into substrings and save it in a names array
If UBound (names) <>1 then
The ' UBound function returns the largest subscript of the array names, UBound (names) <>1 indicates that there is an @ character in the email string and more than one, so email is not a valid mailing address format
Isvalidemail=false
Exit function
End If
For each name in names
If Len (name) <=0 Then
Isvalidemail=false
Exit function
End If
For I=1 to Len (name)
C=lcase (Mid (name,i,1))
' Returns the first character in the string name and converts it to lowercase
If InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 and not IsNumeric (c) Then
The ' InStr function returns the position where the specified string appears for the first time in another string. InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <=0 indicates that character C is not in the string "abcdefghijklmnopqrstuvwxyz_-." In
Isvalidemail=false
Exit function
End If
Next
If left (name,1) = "." or Right (name,1) = "." Then
' Returns the leftmost character of the string name, which returns the rightmost character of the string name
Isvalidemail=false
Exit function
End If
Next
If InStr (Names (1), ".") <=0 Then
' The right part of the ' email string does not contain characters '.
Isvalidemail=false
Exit function
End If
I=len (names (1))-instrrev (names (1), ".")
The ' InStrRev function returns the position of the specified string in another string that appears from the end, InStrRev (names (1), ".") Get the character "." The position from the end of the string names (1)
If I<>2 and i<>3 then
' E-mail is last generally CN or COM, with a length of 2 or 3
Isvalidemail=false
Exit function
End If
' There is a string in the email ' ... '
If InStr (email, "...") >0 Then
Isvalidemail=false
End If
End Function
%>