论坛: 网站建设 标题: 帮忙看看ASP注册系统给解释一下代码。 复制本贴地址    
作者: xhwy [xhwy]    论坛用户   登录
<%
Dim str_db_username                         'Holds username in database
Dim str_wanted_username                     'Holds requested username
Dim str_new_usercode 'Holds the newly generate user code
Dim int_random_number         'Holds a random number
Dim int_random_number_max                         'Holds maximum value of random number
Dim int_random_number_min                         'Holds minimum value of random number
Dim str_password 'Holds the password user chose
Dim rs_new_user 'Recordsheet for new user
Dim rs_check_username         'Recordsheet to check usernames originality
IF request.querystring("step") = 2 THEN
                                                    'Set the variables to the forms enetered values
str_wanted_username = Request.form("username")
str_password = Request.form("pw1")
                                                    'Create new database connection
adoCon.Open cString
                                                    'Create new SQL string
strSQL="SELECT * FROM tbl_authors"
                                                    'Create new recordsheet
set rs_check_username=server.CreateObject("ADODB.Recordset")
                                                    'Open the recordsheet and execute sql
rs_check_username.open strSQL,adoCon
                                                    'Loop until record ends
Do While not rs_check_username.EOF
                                                    'Set variable to hold a database username value
str_db_username = rs_check_username("name")
                            'If the variables match then the username is not unique, redirect to error page
IF str_db_username = str_wanted_username THEN Response.redirect("error.asp")
                                                    'Move to next record
rs_check_username.MoveNext
                                                    'Loop
Loop
                                                    'Close n clean!
rs_check_username.Close
Set rs_check_username = Nothing
                                                    'Create a new random number
Randomize
int_random_number_Min = 1
int_random_number_Max = 999999999
int_random_number = Int(((int_random_number_Max-int_random_number_Min+1) * Rnd) + int_random_number_Min)
                                                    'Convert the new number into a string value
int_random_number = Cstr(int_random_number)
                                  'Set the variable to hold the users password, username and random number
str_new_usercode = str_wanted_username + int_random_number + str_password
                                                        'Create a new SQL string
strsql="SELECT * FROM tbl_authors"
                                                        'Create a new recordsheet
set rs_new_user=server.CreateObject("ADODB.Recordset")
                                                        'Set correct cursor and locktypes
rs_new_user.CursorType = 2
rs_new_user.LockType = 3
                                                        'Open recordsheet and execute SQL string
rs_new_user.open strsql,adocon
                                                        'Set recordsheet to add a new record
rs_new_user.AddNew
                                                        'Enter a new record into the database
rs_new_user.fields("name")= Request.form("username")
rs_new_user.fields("email")= Request.form("email")
rs_new_user.fields("password")= Request.form("pw1")
rs_new_user.fields("code") = str_new_usercode
                                                        'Update the recorsheet
rs_new_user.update
                                                        'Close and clean
rs_new_user.close
set rs_new_user = nothing
adoCon.close
                                                          'Redirect user to step 4
response.redirect("welcome.asp")
else
end if
%>

地主 发表时间: 04-12-05 13:40

回复: RunwinY [runwin]   论坛用户   登录
看 ' 符号后面的就是了,人家都注释了,还用说吗?

B1层 发表时间: 04-12-09 18:28

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号