ASP. NET logon interface: user verification code and. net Logon Interface
// ASP. NET user logon interface often uses the Verification Code as follows: private void Page_Load (object sender, System. eventArgs e) {// place the user code here to initialize the Label4.Text = RandomNum (4);} public string RandomNum (int n) // {string strchar =, 4, 5, 6, 7, 8, 9 "; string [] VcArray = strchar. split (','); string VNum = ""; // The StringBuilder int temp =-1 is not required because the string is short; // records the last random value, avoid generating several identical Random numbers. // use a simple algorithm to ensure that different Random numbers are generated. rand = new Random (); for (int I = 1; I <n + 1; I ++) {if (temp! =-1) {rand = new Random (I * temp * unchecked (int) DateTime. now. ticks);} // int t = rand. next (35); int t = rand. next (10); if (temp! =-1 & temp = t) {return RndNum (n);} temp = t; VNum + = VcArray [t];} return VNum; // return the generated random number} // ''function name: RndNum //'' function parameter: VCodeNum -- set the number of digits returned to the random string // ''function: generate random string private string RndNum (int VcodeNum) {string Vchar = ", A, B, C, D, E, f, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, W, X, Y, Z "; string [] VcArray = Vchar. split (",". toCharArray (); // generates an array string VNum = ""; int I; for (I = 1; I <VcodeNum; I ++) {System. random ro = new Random (); double decA = ro. nextDouble (); VNum = VNum + VcArray [Convert. toInt32 (35 * decA)];} // For I = 1 to VcodeNum // Randomize // VNum = VNum & VcArray (Int (35 * Rnd )) ''array is generally read from 0, so 35 * Rnd // Next return VNum;} // ASP.. NET login interface, user verification code, network collection and testing
How can I implement the user verification code on the ASP NET logon interface?
// ASP. NET user logon interface often uses the Verification Code as follows: private void Page_Load (object sender, System. eventArgs e) {// place the user code here to initialize the Label4.Text = RandomNum (4);} public string RandomNum (int n) // {string strchar =, 4, 5, 6, 7, 8, 9 "; string [] VcArray = strchar. split (','); string VNum = ""; // The StringBuilder int temp =-1 is not required because the string is short; // records the last random value, avoid generating several identical Random numbers. // use a simple algorithm to ensure that different Random numbers are generated. rand = new Random (); for (int I = 1; I <n + 1; I ++) {if (temp! =-1) {rand = new Random (I * temp * unchecked (int) DateTime. now. ticks);} // int t = rand. next (35); int t = rand. next (10); if (temp! =-1 & temp = t) {return RndNum (n);} temp = t; VNum + = VcArray [t];} return VNum; // return the generated random number} // ''function name: RndNum //'' function parameter: VCodeNum -- set the number of digits returned to the random string // ''function: generate random string private string RndNum (int VcodeNum) {string Vchar = ", A, B, C, D, E, f, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, W, X, Y, Z "; string [] VcArray = Vchar. split (",". toCharArray (); // generates an array string VNum = ""; int I; for (I = 1; I
Asp User Logon interface code
Login. asp:
<Form name = "login" method = "post" action = "after_login.asp">
Username: <input name = "user_name" size = "12" maxlength = "16"> password: <input name = "password" size = "12" type = "password" maxlength = "16">
<Input align = "absMiddle" id = "image1" name = "image1" src = "images/login.gif" type = "image" WIDTH = "37" HEIGHT = "20">
</Form>
Coon. asp:
<%
Connstr = "DBQ =" + server. mappathuser. mdb ") +"; DRIVER = {Microsoft Access Driver (*. mdb )}"
Set conn = Server. createobject ("ADODB. CONNECTION ")
Conn. Open connstr
%>
+ After_login.asp logon verification page:
<! -- # Include file = "Conn. Asp" -->
<%
Dim UserName, PassWord
UserName = replace (trim (Request. Form ("Username ")),"'","'")
PassWord = replace (trim (Request. Form ("PassWord ")),"'","'")
If UserName = "" or PassWord = "" Then
Response. Write ("<script> alert ('Member login failed! \ N error cause: the member account and password are not filled. '); History. back (); </script> ")
Response. end
End If
If Instr (UserName, ">")> 0 or Instr (UserName, "<")> 0 or Instr (UserName, "=")> 0 or Instr (UserName, "%")> 0 or Instr (UserName, chr (32)> 0 or Instr (UserName ,"? ")> 0 or Instr (UserName," & amp; ...... remaining full text & gt;>