Dopo aver modificato i due file in questo modo, quando vorrai che sia un admin a doversi registrare fai: register.asp?type=admin , altrimenti la registrazione sarà effettuata come utente normale.
register.asp
codice:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
dim varAdm, msg
varAdm = 0
IF Request.QueryString("type") = "admin" THEN
varAdm = 1
msg = "Registrazione Administrator"
END IF
%>
<h2><%=msg%></h2>
<table cellspadding="3" align="center">
<tr>
<td>
<form method="post" action="reg_verify.asp">
Username: <input type="Text" name="user" />
Password: <input type="Password" name="pass" />
Nome: <input type="Text" name="nome" />
Email: <input type="Text" name="email" />
<input type="Submit" value="Registrati" name="submit" />
<input type="hidden" value="<%=varAdm%>" name="bol_admin" />
</form>
</td>
</tr>
</table>
reg_verify.asp
codice:
<%
'Save entered username, password, name and email
Username = Request.Form("user")
Password = Request.Form("pass")
Nome = Request.Form("nome")
Email = Request.Form("email")
is_admin = Request.Form("bol_admin")
if (Username = "") and (Password = "") and (Name = "") then
Response.Write("Compila tutti i campi!")
elseif (Username = "") then
Response.Write("Inserisci l'Username!")
elseif (Password = "") then
Response.Write("Inserisci la password!")
elseif (Nome = "") then
Response.Write("Inserisci il Nome!")
elseif (Email = "") then
Response.Write("Inserisci l'E-mail!")
else
'Build connection
set conn = server.CreateObject ("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mapPath("database.mdb")
'controllo che lo username non sia già presente nel database
trovato=false
set rs = server.CreateObject ("ADODB.Recordset")
sSQL="select * from Utenti where username='" & Username & "'"
rs.open sSQL,conn,3,3
if not rs.eof then
trovato=true
end if
rs.close
set rs = nothing
if not trovato then
'lo username non è presente lo inserisco nel database
sSQL="insert into Utenti "
sSQL=sSQL & " ([Username], [Password], [Nome], Email, is_admin) "
sSQL=sSQL & " values ( "
sSQL=sSQL & "'" & Username & "',"
sSQL=sSQL & "'" & Password & "',"
sSQL=sSQL & "'" & Nome & "',"
sSQL=sSQL & "'" & Email & ","
sSQL=sSQL & "'" & is_admin & "''"
sSQL=sSQL & " )"
conn.execute(sSQL)
conn.close
set conn=nothing
Response.Write("Ciao " & Name & " , la registrazione è avvenuta con successo!")
else
Response.Write("Lo username " & Username & " , è già presente del database!")
end if
end if
%>
Vedi se funziona. Ciao.