Pagina 3 di 6 primaprima 1 2 3 4 5 ... ultimoultimo
Visualizzazione dei risultati da 21 a 30 su 55
  1. #21
    Originariamente inviato da optime
    ragiona. se l'utente ha sbagliato il login tre volte lo blocchi, giusto? quindi devi scrivere nel record dell'utente che è bloccato (non so se hai già un campo, eventualmente aggiungilo).
    Al successivo tentativo di login, devi anche controllare che l'utente non sia bloccato.
    Ma non è quello che sto facendo?

    codice:
    'CONDIZIONE NON RICONOSCIUTO
    else
    
    
    'CONTO I TENTATIVI
    if IsNull(session("tentativi")) then
         session("tentativi") = 1
       else
         session("tentativi") = session("tentativi") + 1
    end if
      
    'SE I TENTATIVI SONO UGUALI A TRE
        if session("tentativi") = 3 then
        
    'BLOCCO L'UTENTE E SETTO IL CAMPO LOCKED A TRUE
         SQLUpdate = "UPDATE codici set Locked = true where userName = '"&strUser&"'"
         response.write SQLUpdate &"
    "
         cn.Execute(SQLUpdate)
         
    'AVVISO CON UN EMAIL L'UTENTE DEL BLOCCO
         SET RS = Server.CreateObject("ADODB.Recordset")
         RS.ActiveConnection = cn
         SQLSelect = "SELECT * FROM codici WHERE userName = '"&strUser&"'"
         RS.Open SQLSelect
         strUserCode = RS("id_user")
         strEMail = RS("UserMail")
    %>
        
         
        <%
        
       RS.Close
       Set RS = Nothing
        
    end if
    
    
    response.write "NON RICONOSCIUTO"
    
    end if
    Se riprova il login:

    codice:
    'CONDIZIONE RICONOSCIUTO: CONTROLLO CHE IL CAMPO LOCKED NON SIA TRUE
    if strLocked = True then %>
    
     
     <%
    response.write ("Attenzione, account bloccato")
    
    'SE E' TRUE CANCELLO IL COOKIE, GENERO CODICE DI SBLOCCO ED AVVISO VIA EMAIL
    
    Response.Cookies("innovatel.it_accesso") = ""
    strUserName = (objRS("userName"))
    SQL3 = "UPDATE codici set CodiceSbloccoAutomatico = '"&strfinal&"' where userName = '"&strUserName&"'"
    response.write SQL3 &"
    "
    cn.Execute(SQL3)

  2. #22
    controlla:

    1. di aver scritto correttamente Locked nel db
    2. di leggere correttamente strLocked dal db

  3. #23
    Dopo i 3 tentativi a vuoto il campo locked del db passa correttamente a true; chiudo il browser riprovo il login ed invece di dirmi account bloccato, mi continua a chiedere l'inserimento della psw anche quando è corretta...

    codice:
    IF not objRS.EOF THEN
    
    response.write "RICONOSCIUTO
    "
    
    
    Response.Cookies("innovatel.it_accesso")("valido")="ok"
      Response.Cookies("innovatel.it_accesso").expires = DateAdd("n", 480, Now())
    
    ...' INIZIALIZZO ALTRE VARIABILI TRA CUI:
    
     strLocked = objRS("Locked")
    
    
      'CONTROLLO SU DATA ... CODICE OMESSO
    ...
    
         if DataVariabile =< 0 OR DataVariabileSem > 180 then %>
     
              response.write "psw scaduta"
    
         end if
    
                if strLocked = True then %>
    
                    
     
    <%
                           response.write "utente bloccato-inviato codice di sblocco"
    
                           Response.Cookies("innovatel.it_accesso") = ""
                           strUserName = (objRS("userName"))
                           SQL3 = "UPDATE tbl set CodiceSbloccoAutomatico = '"&strfinal&"' where userName = '"&strUserName&"'"
                           response.write SQL3 &"
    "
                           cn.Execute(SQL3)

  4. #24
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Ma nella query in cui cerchi l'utente per fare il login controlli se è "locked"?

    Roby

  5. #25
    Si.
    Sbaglio?

  6. #26
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    No è giusto ma non lo vedo...

    Roby

  7. #27
    Ecco il codice quasi completo:

    Codice PHP:
    <%
    ...

    strSql "SELECT * FROM tbl WHERE userName LIKE '"&strUser&"' AND userCode='"&strCode&"'"
    response.write strSQL &"
    "
    objRS.Open strSQL

    if not objRS.EOF THEN


      Response
    .Cookies("innovatel.it_accesso")("valido")="ok"
      
    Response.Cookies("innovatel.it_accesso").expires DateAdd("n"480Now())

    ...
    ' INIZIALIZZO ALTRE VARIABILI TRA CUI:

     strLocked = objRS("Locked")

     
      '
    CONTROLLO SU DATA (CODICE OMESSO)
    ...

         if 
    DataVariabile =< OR DataVariabileSem 180 then %>
     
              
    response.write "psw scaduta"

         
    end if

                if 
    strLocked True then %>

                    
     
    <%
                           
    response.write "utente bloccato-inviato codice di sblocco"

                           
    Response.Cookies("innovatel.it_accesso") = ""
                           
    strUserName = (objRS("userName"))
                           
    SQL3 "UPDATE tbl set CodiceSbloccoAutomatico = '"&strfinal&"' where userName = '"&strUserName&"'"
                           
    response.write SQL3 &"
    "
                           
    cn.Execute(SQL3)

                 else

                            
    strUserName = (objRS("userName"))
                            
    SQL2 "UPDATE tbl set DataUltimoAccesso = #"&DataOdierna&"# where userName = '"&strUserName&"'"
                            
    response.write SQL2 &"
    "
                            
    cn.Execute(SQL2)

                 
    end if


        
     
    else

    if 
    IsNull(session("tentativi")) then
         session
    ("tentativi") = 1
       
    else
         
    session("tentativi") = session("tentativi") + 1
    end 
    if
      
        if 
    session("tentativi") = 3 then
        
         SQLUpdate 
    "UPDATE tbl set Locked = true where userName = '"&strUser&"'"
         
    response.write SQLUpdate &"
    "
         
    cn.Execute(SQLUpdate)
         
         
    SET RS Server.CreateObject("ADODB.Recordset")
         
    RS.ActiveConnection cn
         SQLSelect 
    "SELECT * FROM tbl WHERE userName = '"&strUser&"'"
         
    RS.Open SQLSelect
         strEMail 
    RS("UserMail")
    %>
        
         
        <%
        
       
    RS.Close
       Set RS 
    Nothing

        end 
    if


    response.write "NON RICONOSCIUTO"

    end if
     
        
      
    ChiudiDB()
      
     
    Sub ChiudiDB()
       
    objRS.Close
       Set objRS 
    Nothing
      cn
    .Close
      Set cn 
    Nothing
    End Sub

    %> 

  8. #28
    strSql = "SELECT * FROM tbl WHERE userName LIKE '"&strUser&"' AND userCode='"&strCode&"'"

    fai una LIKE per lo UserName?

  9. #29
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    1) strSql = "SELECT * FROM tbl WHERE userName LIKE '"&strUser&"' AND userCode='"&strCode&"'"

    E' qui che devi mettere il controllo del locked

    2) Perché usi la LIKE?

    Roby

  10. #30
    e cmq, basterebbe mettere il controllo del blocco PRIMA del controllo della data...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.