<% Option Explicit Dim strError, strSQL 'see if the form has been submitted If Request.Form("action")="register" Then 'the form has been submitted '// validate the form 'check if a username has been entered If Request.Form("username") = "" Then _ strError = strError & "- Please enter a username
" & vbNewLine 'check if a password has been entered If Request.Form("password") = "" Then _ strError = strError & "- Please enter a password
" & vbNewLine 'check if the passwords are the same... but don't display it if the password field is blank. If Request.Form("password") <> Request.Form("password_confirm") _ And Request.Form("password") <> "" Then _ strError = strError & "- Your passwords do not match
" & vbNewLine '// check if an error has occured If strError = "" Then 'continue 'include database connection code %> <% On Error Resume Next '// create the SQL strSQL = "INSERT INTO members ([username],[password]) VALUES " & _ "('" & fixQuotes(Request.Form("username")) & "','" & _ fixQuotes(Request.Form("password")) & "')" '// run the SQL objConn.Execute strSQL '// check for an error '// ATTENTION: this should be changed depending on the database provider If Err.Number = -2147467259 Then strError = "- That username is already in use. Please choose another
" & vbNewLine ElseIf Err.Number <> 0 Then strError = "- An error occured. " & Err.Number & " : " & _ Err.Description & "
" & vbNewLine Else 'record created... redirect Response.Redirect "login.asp?msg=" & Server.URLEncode("Thank you for registering") Response.End End If 'restore standard error handling On Error Goto 0 End If If strError <> "" Then 'output the error message 'add extra HTML... strError = "

The following errors occured:" & _ "
" & vbNewLine & strError End If End If Function fixQuotes(strData) fixQuotes = Replace(strData,"'","''") End Function %> My Website's Registration Page

Member Registration

Please fill out the following form to register as a member, and gain access to our members area.

<%=strError%>
Username ">
Password ">
Password Confirm ">