Vi posto il codice che, da inesperto del tema, ho generato per il controllo di un accesso utente ad un sito. Accetto sicuramente consigli per migliorarlo/renderlo decente, ma mi assilla un problema:
Le opzioni:Codice PHP:<%
username = Trim(Request("logVar"))
password = Trim(Request("pwdVar"))
email = Trim(Request("emailVar"))
'Option Explicit
Dim objConn1, objRs1, strConn, strsql
Dim objConn2, objRs2
Dim objConn3, objRs3
Dim objConn4, objRs4
strConn = Application("dbconn")
'Prova 1: testare login presente con mail diversa
strsql="SELECT tblUtenti.LogUt, tblUtenti.emailUt FROM tblUtenti WHERE (((tblUtenti.LogUt)='" & username & "') AND ((tblUtenti.emailUt)<>'" & email & "'));"
Set objConn1 = Server.CreateObject("ADODB.Connection")
objConn1.Open strConn
Set objRs1 = objConn1.Execute (strsql)
if NOT objRs1.EOF then
'ho trovato un record
response.write "EsitoLog=login già presente"
else
'Prova 2: testare mail presente con login diversa
strsql="SELECT tblUtenti.LogUt, tblUtenti.emailUt FROM tblUtenti WHERE (((tblUtenti.LogUt)<>'" & username & "') AND ((tblUtenti.emailUt)='" & email & "'));"
Set objConn2 = Server.CreateObject("ADODB.Connection")
objConn2.Open strConn
Set objRs2 = objConn2.Execute (strsql)
if NOT objRs2.EOF then
'ho trovato un record
response.write "EsitoLog=mail già presente"
else
'Prova 3: testare login e mail presenti ed uguali
strsql="SELECT tblUtenti.LogUt, tblUtenti.emailUt FROM tblUtenti WHERE (((tblUtenti.LogUt)='" & username & "') AND ((tblUtenti.emailUt)='" & email & "'));"
Set objConn3 = Server.CreateObject("ADODB.Connection")
objConn3.Open strConn
Set objRs3 = objConn3.Execute (strsql)
if NOT objRs3.EOF then
'ho trovato un record
response.write "EsitoLog=login e mail presenti"
else
'l'utente è nuovo e va inserito
strsql = "INSERT INTO tblUtenti ( LogUt, PwdUt, emailUt ) Values ('" & username & "','" & password & "','" & email & "');"
Set objConn4 = Server.CreateObject("ADODB.Connection")
objConn4.Open strConn
Set objRs4 = objConn4.Execute (strsql)
response.write "EsitoLog=Utente Inserito"
objRs4.Close
Set objRs4 = Nothing
end if
objRs3.Close
Set objRs3 = Nothing
end if
objRs2.Close
Set objRs2 = Nothing
end if
objRs1.Close
Set objRs1 = Nothing
%>
1.controllo login già presente
2.controllo mail già presente
3.controllo login e mail presenti insieme
funzionano, mentre la fase 4, ovviamente la più importante di inserimento nel db, funziona solo se tolgo le 2 righe
altrimenti mi diceCodice PHP:objRs4.Close
Set objRs4 = Nothing
Operation is not allowed when the object is closed.
/Mio/iscrizione.asp, line 48
Qualcuno può darmi una mano?
Grazie

Rispondi quotando