Ciao, come faccio a far funzionare questa serie di IF:codice:if primacondizione then 'FAI QUESTO else IF not objRS.EOF THEN cAMPOUNO = objRS("CAMPOUNO") if CAMPOUNO = True then 'FAI QUELLO else 'FAI ALTRO else 'FAI QUELL'ALTRO end if end if end if
Ciao, come faccio a far funzionare questa serie di IF:codice:if primacondizione then 'FAI QUESTO else IF not objRS.EOF THEN cAMPOUNO = objRS("CAMPOUNO") if CAMPOUNO = True then 'FAI QUELLO else 'FAI ALTRO else 'FAI QUELL'ALTRO end if end if end if
bhe di sicuro due else così non vanno,o manca un end if in mezzo oppure uno è un elseif...
else
'FAI ALTRO
else
poi sei sicuro di non poter usare select case al posto di qualche if?
Infatti, questo è il codice completo...
codice:if DataVariabile > 90 then %> <script language="javascript"> alert("KO"); location.href='../index.asp'; </script> <% else IF not objRS.EOF THEN Locked = objRS("Locked") if Locked = True then %> <script language="javascript"> alert("KO"); location.href='../index.asp'; </script> <% else session.sessionID data = convertDate(date()) tempo = time() Sql = "INSERT INTO TABELLA (DATA, ORA, SESSIONID) VALUES (#"&data&"#, '"&tempo&"', "&session.sessionID&")" cn.Execute(SQL) else SET RS = Server.CreateObject("ADODB.Recordset") SQLSelect = "SELECT * FROM tabella WHERE userName = '"&strUser&"'" RS.Open SQLSelect strUserCode = RS("id_user") if IsNull(session("tentativi")) then session("tentativi") = 1 else session("tentativi") = session("tentativi") + 1 end if if session("tentativi") = 3 then SQLUpdate = "UPDATE codici set Locked = true where id_user = "&strUserCode cn.Execute(SQLUpdate) RS.Close Set RS = Nothing end if end if objRS.Close Set objRS = Nothing cn.Close Set cn = Nothing End if
premesso che non hai detto che errore da e cosa vuoi ottenere...
il problema rimane anche nel codice "completo" (non credo sia completo visto che il secondo if fa riferiemnto ad un oggetto recordset creato nn si sa dove...)
o manca un end if o cmq c'è qualcosa che nn va...
else
session.sessionID
data = convertDate(date())
tempo = time()
Sql = "INSERT INTO TABELLA (DATA, ORA, SESSIONID) VALUES (#"&data&"#, '"&tempo&"', "&session.sessionID&")"
cn.Execute(SQL)
else
Vorrei bloccare l'accesso all'utente in cui il campo Locked è true e dovrei inserire nel codice sottostante questo ulteriore controllo:Ho provato in varie combinazioni ma non riesco a farlo funzionare all'interno di questo codice:codice:Locked = objRS("Locked") if Locked = True then %> <script language="javascript"> alert("Attenzione, account bloccato!\nRivolgersi all'amministratore del sistema."); location.href='../index.asp'; </script> <% end if %>codice:strSql = "SELECT * FROM codici WHERE userName='"&strUser&"' AND userCode='"&strCode&"'" objRS.Open strSQL DataScadenzaUserCode = convertDate(objRS("DataScadenzaUserCode")) DataRegistrazioneUserCode = convertDate(objRS("DataRegistrazioneUserCode")) DataVariabile = (DateDiff("d",DataRegistrazioneUserCode,DataScadenzaUserCode)) if DataVariabile > 90 then %> <script language="javascript"> alert("Attenzione, account bloccato!\nLa password è scaduta.\nCambiare la password.\nSarai reindirizzato alla pagina principale."); location.href='../index.asp'; </script> <% else IF not objRS.EOF THEN Response.Cookies("innovatel.it_accesso")("valido")="ok" Response.Cookies("innovatel.it_accesso").expires = DateAdd("n", 60, Now()) Response.Cookies("innovatel.it_accesso")("nome")=objRS("utente_id") Session("user") = Request("user") Session("id_utente") = objRS("utente_id") strEmail = objRS("userMail") strUserCode = objRS("id_user") strLocked = objRS("Locked") session.sessionID data = convertDate(date()) tempo = time() Sql = "INSERT INTO ACCESSI (UTENTE, DATA, ORA, SESSIONID, strEmail) VALUES ('"&strUser&"', #"&data&"#, '"&tempo&"', "&session.sessionID&", '"&strEmail&"')" cn.Execute(SQL) else SET RS = Server.CreateObject("ADODB.Recordset") RS.ActiveConnection = cn SQLSelect = "SELECT * FROM codici WHERE userName = '"&strUser&"'" RS.Open SQLSelect strUserCode = RS("id_user") if IsNull(session("tentativi")) then session("tentativi") = 1 else session("tentativi") = session("tentativi") + 1 end if if session("tentativi") = 3 then SQLUpdate = "UPDATE codici set Locked = true where id_user = "&strUserCode cn.Execute(SQLUpdate) RS.Close Set RS = Nothing end if end if ChiudiDB() Response.Redirect Request.Form("referer") Sub ChiudiDB() objRS.Close Set objRS = Nothing cn.Close Set cn = Nothing End Sub End if
io farei + o - una cosa del genere,tieni conto che non ho fatto nessuna prova,l'ho solo scritto al volo cercando di "interpretare" quello che vuoi ottenere e non conoscendo la tua base dati:
codice:<% Dim CodiceErrore '...apri db strSql = "SELECT * FROM codici WHERE userName='"&strUser&"' AND userCode='"&strCode&"'" SET objRS= Server.CreateObject("ADODB.Recordset") objRS.ActiveConnection = cn objRS.Open strSQL If objRS.EOF THEN CodiceErrore=1 else CodiceErrore=0 DataScadenzaUserCode = convertDate(objRS("DataScadenzaUserCode")) DataRegistrazioneUserCode = convertDate(objRS("DataRegistrazioneUserCode")) DataVariabile = (DateDiff("d" ,DataRegistrazioneUserCode,DataScadenzaUserCode)) strEmail = objRS("userMail") strUserCode = objRS("id_user") strLocked = objRS("Locked") if strLocked = True then CodiceErrore=2 end if if DataVariabile > 90 then CodiceErrore=3 end if end if Select case CodiceErrore: case 0: Session("user") = Request("user") Session("id_utente") = objRS("utente_id") Response.Cookies("innovatel.it_accesso")("valido")="ok" Response.Cookies("innovatel.it_accesso").expires = DateAdd("n", 60, Now()) Response.Cookies("innovatel.it_accesso")("nome")=objRS("utente_id") data = convertDate(date()) tempo = time() Sql = "INSERT INTO ACCESSI (UTENTE, DATA, ORA, SESSIONID, strEmail) VALUES ('"&strUser&"', #"&data&"#, '"&tempo&"', "&session.sessionID&", '"&strEmail&"')" cn.Execute(SQL) ChiudiDB() Response.Redirect Request.Form("referer") case 1: if IsNull(session("tentativi")) then session("tentativi") = 1 else session("tentativi") = session("tentativi") + 1 end if if session("tentativi") = 3 then SQLUpdate = "UPDATE codici set Locked = true where userName = '"&strUser&"' AND userCode='"&strCode&"'" cn.Execute(SQLUpdate) end if ChiudiDB() %> <script language="javascript"> alert("Attenzione, username e password incorretti!\nTentativo login n° <%=session("tentativi")%>"); location.href='../index.asp'; </script> <% case 2: %> <script language="javascript"> alert("Attenzione, account bloccato!\nRivolgersi all'amministratore del sistema."); location.href='../index.asp'; </script> <% case 3: %> <script language="javascript"> alert("Attenzione, account bloccato!\nLa password è scaduta.\nCambiare la password.\nSarai reindirizzato alla pagina principale."); location.href='../index.asp'; </script> <% case else: End Select Sub ChiudiDB() objRS.Close Set objRS = Nothing cn.Close Set cn = Nothing End Sub
Capperi...ma indentare un pò il codice per far capire quello che vuoi????Originariamente inviato da fraude
Ciao, come faccio a far funzionare questa serie di IF:codice:if primacondizione then 'FAI QUESTO else IF not objRS.EOF THEN cAMPOUNO = objRS("CAMPOUNO") if CAMPOUNO = True then 'FAI QUELLO else 'FAI ALTRO else 'FAI QUELL'ALTRO end if end if end ifVVoVe:
Roberto Pazzini
Ho provato il tuo codice, diverse cose non funzionano, una su tutte che anche l'utente che inserisce login e password esatte non viene più riconosciuto dal sistema...![]()
bhe fai un pò di debug,ti avevo avvisato che nn l'ho provato,metti
response.write CodiceErrore
response.end
prima del select case e controlla che valorizzi la variabile in modo corretto secondo quella che dovrebbe essere la logica.se questo è corretto già siamo a buon punto,se no vuol dire che ancora nemmeno ho capito cosa vuoi tirarne fuori...