'Function name: chk_email ()
'Return value: Boolean value (true indicates pass, false indicates fail)
'Parameter: email (the email to be judged, type: string) type_1 (whether to determine the domain after @, type: Boolean)
'Type _ 2 (whether it can only be registered by E-mail in a specific domain, type: Boolean value) type_3 (whether an e-mail can only be registered once, type: Boolean value)
Const c_maildomain = ". com, .com.cn ,. net, .net.cn ,. org, .org.cn ,. gov, .gov.cn ,. edu, .edu.cn ,. CN ,. CC ,. biz ,. info "'email acceptable domain
Const c_lockdomain = "bit.edu.cn, loster.org" 'specific domain
Function chk_email (email, type_1, type_2, type_3)
Dim I, K
Dim
Dim email_1, temp
If email = "" then
Chk_email = false
Exit Function
End if
Email_1 = CSTR (TRIM (email ))
If Len (email_1) <5 then
Chk_email = false
Exit Function
End if
At = false
For I = 1 to Len (email_1)
Temp = mid (email_1, I, 1)
If temp = "@" then
At = true
Exit
End if
Next
If at = false then
Chk_email = false
Exit Function
End if
K = 0
For I = 1 to Len (email_1)
Temp = mid (email_1, I, 1)
If temp = "." Then
K = k + 1
End if
Next
If K = 0 or k> 2 then
Chk_email = false
Exit Function
End if
If type_1 = true then
For I = 1 to Len (email_1)
Temp = mid (email_1, I, 1)
If temp = "@" then
K = I
Exit
End if
Next
For I = K to Len (email_1)
Temp = mid (email_1, I, 1)
If temp = "." Then
K = I
Exit
End if
Next
Temp = ""
For I = K to Len (email_1)
Temp = temp + mid (email_1, I, 1)
Next
Temp = CSTR (TRIM (temp ))
At = false
For I = 0 to r_reader (c_maildomain ,",")
If temp = reader (I) then
At = true
Exit
End if
Next
Erase Reader
If at = false then
Chk_email = false
Exit Function
End if
End if
If type_2 = true then
For I = 1 to Len (email_1)
Temp = mid (email_1, I, 1)
If temp = "@" then
K = I
Exit
End if
Next
Temp = ""
For I = k + 1 to Len (email_1)
Temp = temp + mid (email_1, I, 1)
Next
Temp = CSTR (TRIM (temp ))
At = false
For I = 0 to r_reader (c_lockdomain ,",")
If temp = reader (I) then
At = true
Exit
End if
Next
Erase Reader
If at = false then
Chk_email = false
Exit Function
End if
End if
If type_3 = true then
Dim J
Call greate_userdb ()
Call create_rs ("select * From user_basic_info where user_email = '" & email_1 & "'", 1, 1, "user ")
If Rs. bof = false then
Chk_email = false
Call close_rs ()
Call close_userdb ()
Exit Function
End if
Call close_rs ()
Call close_userdb ()
End if
Chk_email = true
End Function
Dim user_db, user_driver
Dim user_conn
User_db = "Data/userdata. mdb"
'Create user_conn' Process
Sub greate_userdb ()
User_driver = "driver = {Microsoft Access Driver (*. mdb )}"
User_driver = user_driver & "; DBQ =" & server. mappath (user_db)
'Response. Write (user_driver)
Set user_conn = server. Createobject ("ADODB. Connection ")
User_conn.open (user_driver)
End sub
'The process of disabling user_conn
Sub close_userdb ()
User_conn.close
Set user_conn = nothing
End sub
Dim Reader
Dim rs
'Read constants and save each constant in the reader array. parameters: r_str (constant string), f_str (separator), return value: subscript of the reader Array
Function r_reader (r_str, f_str)
Dim I
If r_str = "" Or f_str = "" then
Exit Function
End if
Reader = Split (r_str, f_str)
For I = 0 to ubound (reader, 1)
Reader (I) = CSTR (TRIM (Reader (I )))
Next
R_reader = ubound (reader, 1)
End Function