ASP Access User Registration instance

Source: Internet
Author: User

<!--#include file= "conn.asp"-->
<!--#include file = "procedure.asp"-->
<!--#include file= "md5.asp"-->
<%
Sub Save ()
Dim username,userpwd,pwd,name,email
' reads the username data from the table conveys, and the trim function removes the leading and trailing spaces of the string
Username=trim (Request.Form ("username"))
Userpwd=trim (Request.Form ("Userpwd"))
Pwd=trim (Request.Form ("pwd"))
Name=trim (Request.Form ("name"))
Email=trim (Request.Form ("email"))
' User input is not complete
If Username= "" or userpwd= "" or pwd= "" or name= "" or email= "" "Then
' Give a hint and return to the registration page. History.back () means to return to the registration page
Response.Write "<script>alert (' Input information incomplete!") '); History.back ();</script> "
Response.End
End If
If Userpwd<>pwd then ' two input passwords are not the same
' Give a hint and return to the registration page
Response.Write "<script>alert (' two input passwords are not the same! '); History.back ();</script> "
Response.End
End If
' IsValidEmail procedure to determine if the e-mail address format that the user entered is correct
If not isvalidemail (email) Then
' Email address format error, give prompt and return to registration page
Response.Write "<script>alert (' email address format is wrong! '); History.back ();</script> "
Response.End
End If
' Determine if there is a user input user name in the database tutorial
Set Hvrs=server.createobject ("Adodb.recordset")
' Look for records from the database that have a value of username column username
Sql= "SELECT * from user where username= '" & Username & "'"
Hvrs.open sql,conn,1,1
If not (hvrs.eof and hvrs.bof) Then ' there are records that meet the criteria
' User name exists in the database, give a hint and return to the registration page
Response.Write "<script>alert (' the username already exists! Please re-fill in ... '); History.back ();</script> "
Response.End
Else ' There is no record to meet the criteria
' Insert a new record in the database
Set Rs=server.createobject ("Adodb.recordset")
Sql= "Select Username,password,name,email from User"
Rs.Open sql,conn,1,3
Rs.addnew
RS ("username") =username ' user login name
RS ("password") =md5 (userpwd) ' User login password
RS ("name") =name ' user's real name
RS ("email") =email ' user e-mail
Rs.update ' Update database
Rs.close
End If
Hvrs.close
Set hvrs=nothing
End Sub
%>


<link rel= "stylesheet" href= "images/styles.css Tutorial" type= "Text/css" >
<title> Chat Room </title>

<body leftmargin= "0" topmargin= "0" marginwidth= "0" marginheight= "0" >
<p align= "center" style= "Margin-top:10" >
<font size= "6" > Chat Room Registration Wizard </font>
</p>

<center>
<%
If Request.QueryString ("result") = "successful" Then
Call Save ()
Call Show ()
Else
Call Main ()
End If
%>
</center>
<%sub Main ()%>
<center>
<form method= "POST" action= "Register.asp?result=successful" name=registerform>
<table border= "0" width= "625" cellspacing= "1" height= ">"
<tr>
&LT;TD width= "472" colspan= "2" height= "align=center>"
<p align= "center" >
<b> Basic Information Settings </b><br><br>
</p>
</td>
</tr>
<tr>
&LT;TD width= "126" height= "8" bgcolor= "#c0c0c0" >
<p align= "center" >
<font color= "#000000" size= "2" > User account:</font>
</p>
</td>
&LT;TD width= "485" height= "8" >
<input name= "username" size= "class=" "BK" >&nbsp;<font color= "#ff0000" >
<font size= "2" >*</font></font><font color= "#000000" size= "2" > Please enter the username you want to register </font>
</td>
</tr>
<tr>
&LT;TD width= "126" height= "8" bgcolor= "#c0c0c0" >
<p align= "center" >
<font color= "#000000" size= "2" > User password:</font>
</p>
</td>
&LT;TD width= "485" height= "1" >
<p align= "Left" >
<input type= "Password" name= "userpwd" size= "" class= "BK" >&nbsp;<font color= "#ff0000" >
<font size= "2" >*</font></font><font color= "#000000" size= "2" > Authentication for login System </font>
</p>
</td>
</tr>
<tr>
&LT;TD width= "126" height= "8" bgcolor= "#c0c0c0" >
<p align= "center" >
<font color= "#000000" size= "2" > Password confirmation:</font>
</p>
</td>
&LT;TD width= "485" height= ">"
<input type= "password" name= "pwd" size= "" class= "BK" >&nbsp;<font color= "#ff0000" >
<font size= "2" >*</font></font><font size= "2" > Confirm password </font>
</td>
</tr>
<tr>
&LT;TD height= "8" width= "126" bgcolor= "#c0c0c0" >
<p align= "center" >
<font size= "2" > real name:</font>
</p>
</td>
&LT;TD height= "1" width= "559" >
<input type= "text" name= "name" size= "" class= "BK" >&nbsp;<font color= "#ff0000" >
<font size= "2" >*</font></font><font size= "2" > Please enter your real name </font>
</td>
</tr>
<tr>
&LT;TD height= "8" width= "126" bgcolor= "#c0c0c0" >
<p align= "center" >
<font size= "2" > E-mail:</font>
</p>
</td>
&LT;TD height= "1" width= "559" >
<input type= "text" name= "email" size= "class=" BK "style=" ime-mode:disabled ">&nbsp;<font color=" # ff0000 ">
<font size= "2" >*</font></font><font size= "2" > Please enter your email </font>
</td>
</tr>
<tr>
&LT;TD width= "472" colspan= "2" height= ">"
<p align= "center" >
<p align= "center" >
<input type= "Submit" value= "submitted" name= "register" class= "Tips Tutorial _bo" >
</td>
</tr>
</table>
</form>
<%end sub%>
<%sub Show ()%>
<table border= "0" width= "71%" cellspacing= "1" height= ">"
<tr>
&LT;TD width= "100%" height= ">"
<p align= "center" >
<font color= "#ff0000" >
<b> User Registration Success </b>
</font>
</p>
</td>
</tr>
<tr>
&LT;TD width= "100%" height= ">"
<p align= "center" >
<font color= "#ffffff" > Your information settings have been successful, enter the chat room click "Finish" </font>
</p>
<p align= "center" >[<a href= "index.asp" ><b> completion </b></a>]
</td>
</tr>
</table>
<%end sub%>
</body>

<%
Set rs=nothing
Conn.close
Set conn=nothing
%>

Download this section instance source code

Http://down.111cn.net/down/code/asp/2010/1024/21402.html

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.