Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it L'avatar di alkresl
    Registrato dal
    Feb 2005
    Messaggi
    270

    chat con login e registrazione...

    hey raga.. io ho diciamo una piccola chat che uso x i cell, ma molte volte degli utenti che nn hanno nulla da fare, vengono a rompere... quindi vorrei fare in modo che ci si possa registrare, quindi che appena si effettua il login, vorrei che il nickname con cui invia il messaggio, sia lo stesso fatto dal login...
    eco le pagine:
    add_to_guestbook.asp:

    <%


    'Dimension variables
    Dim adoCon 'Holds the Database Connection Object
    Dim rsAddComments 'Holds the recordset for the new record to be added to the database
    Dim strSQL 'Holds the SQL query for the database

    'Create an ADO connection odject
    Set adoCon = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")

    'Set an active connection to the Connection object using DSN connection
    'adoCon.Open "DSN=guestbook"

    'Create an ADO recordset object
    Set rsAddComments = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"

    'Set the cursor type we are using so we can navigate through the recordset
    rsAddComments.CursorType = 2

    'Set the lock type so that the record is locked by ADO when it is updated
    rsAddComments.LockType = 3

    'Open the tblComments table using the SQL query held in the strSQL varaiable
    rsAddComments.Open strSQL, adoCon

    'Tell the recordset we are adding a new record to it
    rsAddComments.AddNew

    'Add a new record to the recordset
    rsAddComments.Fields("Name") = Request.Form("name")
    rsAddComments.Fields("Comments") = Request.Form("comments")

    'Write the updated recordset to the database
    rsAddComments.Update

    'Reset server objects
    rsAddComments.Close
    Set rsAddComments = Nothing
    Set adoCon = Nothing

    'Redirect to the Stanza1.asp page
    Response.Redirect "Stanza1.asp"
    %>

    Stanza1.asp:

    <html>
    <head>
    <title>MiniCellularmania</title>
    </head>
    <body bgcolor="white" text="black">
    <html>
    <head>
    <title>Guestbook</title>
    </head>
    <body bgcolor="white" text="black">
    <%
    'Dimension variables
    Dim adoCon 'Holds the Database Connection Object
    Dim rsGuestbook 'Holds the recordset for the records in the database
    Dim strSQL 'Holds the SQL query for the database




    'Create an ADO connection odject
    Set adoCon = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")

    'Set an active connection to the Connection object using DSN connection
    'adoCon.Open "DSN=guestbook"

    'Create an ADO recordset object
    Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"

    'Open the recordset with the SQL query
    rsGuestbook.Open strSQL, adoCon

    'Loop through the recordset
    Do While not rsGuestbook.EOF

    'Write the HTML to display the current record in the recordset
    Response.Write ("
    ")
    Response.Write (rsGuestbook("Name"))
    Response.Write ("
    ")
    Response.Write (rsGuestbook("Comments"))
    Response.Write ("
    ")

    'Move to the next record in the recordset
    rsGuestbook.MoveNext

    Loop

    'Reset server objects
    rsGuestbook.Close
    Set rsGuestbook = Nothing
    Set adoCon = Nothing
    %>
    </body>
    </html>
    <form name="form" method="post" action="add_to_guestbook.asp">
    NiCK<input type="text" name="name" maxlength="12">


    MSG <input type="text" name="comments" maxlength="140">


    <input type="submit" name="Submit" value="Invia"></p>
    </form>
    </body>
    </html>

    potreste dirmi cosa modificare??
    dovrei creare anke la pagina del login, ma come devo fare x legarli??

  2. #2
    Utente di HTML.it L'avatar di alkresl
    Registrato dal
    Feb 2005
    Messaggi
    270

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Ti serve il login ed assegnare ad una session il nick dell'utente che entrato.
    Guarda qui, ci sono molti script di accesso all'area riservata: http://freeasp.html.it

    Roby

  4. #4
    Utente di HTML.it L'avatar di alkresl
    Registrato dal
    Feb 2005
    Messaggi
    270
    login.asp

    <%
    Dim nome_ut
    Dim pass
    nome_ut = Replace(Request.Form("nome_utente"), "'", "''")
    pass = Replace(Request.Form("password"), "'", "''")

    Dim cn
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath("../mdb-database/utenti.mdb")
    Dim sql
    sql = "SELECT ID FROM Utenti WHERE NOMEUTENTE='" &nome_ut&_
    "' AND PASSWORD='" &pass& "'"
    Dim rs
    Set rs = cn.Execute(sql)

    Dim autenticato
    if rs.eof then
    autenticato = false
    else
    autenticato = true
    end if
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

    if autenticato = true then
    Session("Autenticato") = "OK"
    Response.Redirect("index.asp")
    else
    Response.Redirect("index1a.asp")
    end if
    %>


    index1a.asp

    <HTML>
    <HEAD>
    <TITLE>Autenticazione utente tramite password</TITLE>
    </HEAD>
    <BODY BGCOLOR=#83A6D2>
    <FORM ACTION="login.asp" METHOD="POST">
    <div align="center">
    <center>
    <TABLE BORDER=1 style="border-collapse: collapse" bordercolor="#000080">
    <TR BGCOLOR=#EEEEEE>
    <TD WIDTH=150 ALIGN=CENTER style="border: 1px solid #000080">
    <font size="2" face="Verdana" color="#000080">NOME UTENTE</font>
    </td>
    <TD style="border: 1px solid #000080">
    <INPUT TYPE=TEXT NAME="nome_utente" SIZE=20>
    </td>
    </TR>
    <TR BGCOLOR=#EEEEEE>
    <TD WIDTH=150 ALIGN=CENTER style="border: 1px solid #000080">
    <font size="2" face="Verdana" color="#000080">PASSWORD</font>
    </td>
    <TD style="border: 1px solid #000080">
    <INPUT TYPE=PASSWORD NAME="password" SIZE=20>
    </TD>
    </TR>
    <TR BGCOLOR=#EEEEEE>
    <TD HEIGHT=30 COLSPAN=2 ALIGN=CENTER style="border: 1px solid #000080">
    <INPUT TYPE=submit NAME="show" VALUE=" LOGIN " style="color: #FFFFFF;

    font-size:10 px; background-color:#000080">
    </TD>
    </TR>
    </TABLE>
    </center>
    </div>
    </FORM>
    </BODY>
    </HTML>

    index1a.asp

    <%
    Dim nome_ut
    Dim pass
    nome_ut = Replace(Request.Form("nome_utente"), "'", "''")
    pass = Replace(Request.Form("password"), "'", "''")

    Dim cn
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath("../mdb-database/utenti.mdb")
    Dim sql
    sql = "SELECT ID FROM Utenti WHERE NOMEUTENTE='" &nome_ut&_
    "' AND PASSWORD='" &pass& "'"
    Dim rs
    Set rs = cn.Execute(sql)

    Dim autenticato
    if rs.eof then
    autenticato = false
    else
    autenticato = true
    end if
    rs.Close
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

    if autenticato = true then
    Session("Autenticato") = "OK"
    Response.Redirect("index.asp")
    else
    Response.Redirect("index1a.asp")
    end if
    %>


    eccoli, ma cosa devo modificare??

  5. #5
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Ma che li hai copiati e basta?
    Devi assegnare il login alla session

    Session("Autenticato") = variabilenick

    Roby

  6. #6
    Utente di HTML.it L'avatar di alkresl
    Registrato dal
    Feb 2005
    Messaggi
    270


    scusa.. ho messo anche una pagina che nn serviva... cmq dove lo devo inserire " Session("Autenticato") = variabilenick " ??

  7. #7
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Al posto di quello che hai tu!

    Roby

  8. #8
    Utente di HTML.it L'avatar di alkresl
    Registrato dal
    Feb 2005
    Messaggi
    270
    e basta?? poi nn devo fare nulla??

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.