In this page, the new visitor enters his firstname,lastname, a username and a password and hits Submit to get login details. If a visitor has already has login details and wants to change the password, they simply enter again all the details in this page and enter the new password and hit submit. Once submitted, the process is carried out in Register.asp which inserts his/her details in the database. The following is the code for the register.asp page
<%@ Language=VBScript %>
<%
Dim sSQL,conn,rs
Set conn = Server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("login.mdb")
conn.open
strsql = "Select firstname,lastname from login"
set rs = conn.Execute (strsql)
if (rs.BOF)and (rs.EOF) then
sSQL = "Insert into admin (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText
else
SQL = "Delete * from login where username= '" & Request.Form("userid") & "'"
conn.execute(SQL)
end if
sSQL = "Insert into login (Firstname,lastname,username,password) Values" & _
"('"& Ucase(Request("firstname")) & "', '"& Request("lastname") & "', '"&
Request("userid") & "', '" & Request("password") & "')"
conn.Execute sSQL,adCmdText
'close the recordset
rs.close
set rs = nothing
'close the connection
conn.close
set conn = nothing
%>