Visualizzazione dei risultati da 1 a 6 su 6

Discussione: problemi asp

  1. #1

    problemi asp

    questo è lo script di una pagina in asp chiamata verifica.asp


    <html>

    <head>
    <title>SEZIONI RISERVATE</title>
    </head>

    <body>



    </p>
    <p align="center"><font face="Verdana" size="3">Sezioni Riservate - Login</font></p>

    <%
    Username = Request.Form("username")
    Password = Request.Form("password")

    IF Username <> "" and Password <> "" then

    dim conn, strConn
    strDataBasePath = "/mdb-database/database.mdb"
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strDataBasePath)
    Set conn = Server.CreateObject("ADODB.Connection")
    Conn.Open StrConn

    SQL = "SELECT * FROM Utenti where username = "" & username &"" and password = "" & password &"" and attivo = 1"

    Set recSet = Server.CreateObject("ADODB.Recordset")

    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic

    IF Not RecSet.Eof Then
    Session("Loggato") = True
    Session("Username") = Username
    Else

    Session("Loggato") = False
    End IF

    RecSet.Close
    Set RecSet = Nothing

    Conn.Close
    Set Conn = Nothing

    IF Session("Loggato") = True then

    Response.Redirect "protetta_home.asp"

    Else

    %>
    <hr>
    <p align="center"><font face="Verdana" size="2">Username/Password non corretti!</font></p>
    <hr>
    <%
    End IF

    Else

    %>
    <hr>
    <p align="center"><font face="Verdana" size="2">Compila correttamente tutti i campi!</font></p>
    <hr>
    <%
    End IF
    %>
    </body>
    </html>




    non riesco a capire come mai anche se inserisco i dati username e password corretti mi da sempre password/username errati


    spero possiate aiutarmi grazie

  2. #2
    codice:
    SQL = "SELECT * FROM Utenti WHERE [username] = '" & username &"' AND [password] = '" & password &"' and attivo = 1"
    Copiala così com'è.

  3. #3
    grazie adesso funziona, però adesso ho riscontrato un altro problema

    questo è lo script della pagina registrati2.asp

    alla quale si viene collegati dopo aver inserito i dati in un form

    <html>

    <head>
    <title>SEZIONI RISERVATE</title>
    </head>

    <body>



    </p>
    <p align="center"><font face="Verdana" size="3">Sezioni Riservate - Registrati</font></p>

    <%

    username = Request.Form("username")
    password = Request.Form("password")
    email = Request.Form("email")

    IF username <> "" and password <> "" and Instr(email,"@") > 0 and Instr(email,".") > 0 then

    url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdb-database/database.mdb")

    Set Conn = Server.CreateObject("ADODB.connection")
    conn.Open url_DB

    Set RecSet = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT * FROM Utenti where username = '" & username &"'"
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic

    IF Not RecSet.Eof Then

    usato = True

    Else

    usato = False
    End IF

    RecSet.Close
    Set RecSet = Nothing

    IF usato = True then

    %>
    <hr>
    <p align="center"><font face="Verdana" size="2">Username inserito già in uso!</font></p>
    <hr>
    <%
    Else

    Set RecSet = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT * FROM Utenti Order By ID Desc"
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic

    RecSet.Addnew

    RecSet("username") = username
    RecSet("password") = password
    RecSet("email") = email


    RecSet("attivo") = 0

    RecSet.Update
    RecSet.Close
    Set RecSet = Nothing

    Set RecSet = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT ID FROM Utenti Where username = '" & username & "' and password = '" & password &"'"
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic

    ID = RecSet("ID")

    RecSet.Close
    Set RecSet = Nothing

    Conn.Close
    Set Conn = Nothing

    mittente = "chivasgroup@hotmail.it"

    testo = "Caro utente," & chr(13)
    testo = testo & "per attivate la registrazione al nostro sito, fai click sul link qui sotto" & chr(13)
    testo = testo & "http://localhost/pagineriservate/attiva.asp?ID="& id &""& chr(13) & chr(13)
    testo = testo & "Lo staff di Mio sito!" & chr(13)
    testo = testo & "http://www.sitomio.it"

    email.From = mittente
    email.To =email
    email.subject = "[MIO SITO] ATTIVA LA REGISTRAZIONE!"
    email.Body = testo
    email.Send

    Set email = nothing
    %>
    <hr>
    <p align="center"><font face="Verdana" size="2">Ti è stata inviata una email per confermare la registrazione!</font></p>
    <hr>
    <%
    End IF
    Else

    %>
    <hr>
    <p align="center"><font face="Verdana" size="2">Compila tutti i dati corretamente!</font></p>
    <hr>
    <%
    End IF
    %>
    </body>
    </html>


    il problema è che mi dice sempre che i dati sono gia stati inseriti ed inoltre avrebbe dovuto inviare un'e-mail all'indirizzo che inserisco che permettesse di attivare la registrazione solo che non me la manda spero possiate nuovamente aiutarmi grazie

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Modifica intanto il campo username nella query come detto da Mems...

    Roby

  5. #5
    fatto ma mi da questo errore adesso

    ADODB.Recordset (0x800A0E78)
    L'operazione non è consentita se l'oggetto è chiuso.
    /pagineriservate/registrati2.asp, line 29

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    E cosa c'entra con l'errore di prima?
    Controlla quella riga.

    Roby

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.