Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    aiuto spam in guestbook

    Non riesco ad integrare un controllo spam nel mio guestbook....
    ho trovato in rete questo articolo interessante http://www.mrwebmaster.it/asp/artico...terne_914.html e vorrei integrare il codice nel mio guest book ma non so come fare!!premetto che sono alle prime armi con la programmazione.

    il mio guest book è cosi composto
    aggiungi.asp
    codice:
    <html>
    
    <head>
    <title>MIO GUESTBOOK</title>
    </head>
    
    <body>
    <p align="center"><font size="4" face="Verdana">Aggiungi un Messaggio nel GuestBook</font></p>
    
    <form method="POST" action="inserisci.asp">
    
    <table border="0" cellpadding="0" cellspacing="0" width="64%">
      <tr>
        <td width="28%"><font face="Verdana" size="2">Titolo Commento:</font></td>
        <td width="72%"><font face="Verdana" size="2"><input type="text" name="titolo" size="20"></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Commento:</font></td>
        <td width="72%"><font face="Verdana" size="2"><textarea rows="5" name="commento" cols="36"></textarea></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Nome:</font></td>
        <td width="72%"><font face="Verdana" size="2"><input type="text" name="autore" size="20"></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Email:</font></td>
        <td width="72%"><font face="Verdana" size="2"><input type="text" name="email" size="20"></font></td>
      </tr>
      <tr>
        <td width="100%" colspan="2"><input type="submit" value="Invia" name="B1"><input type="reset" value="Reimposta" name="B2"></td>
      </tr>
    </table>
    </form>
    <p align="center"><font size="2" face="Verdana"><a href="guestbook.asp">Leggi
    GuestBook</a></font></p>
    
    </body>
    
    </html>
    guestbook.asp
    codice:
    <html>
    
    <head>
    <title>MIO GUESTBOOK</title>
    </head>
    
    <body>
    <p align="center"><font size="4" face="Verdana">Messaggi GuestBook</font></p>
    
    
    <%
    ' NUMERO DI MESSAGGI PER PAGINA
    iPageSize = 5
    
    If Request.QueryString("page") = "" Then 
    iPageCurrent = 1 
    Else 
    iPageCurrent = CInt(Request.QueryString("page")) 
    End If 
    
    If Request.QueryString("order") = "" Then 
    strOrderBy = "id" 
    Else 
    strOrderBy = Request.QueryString("order") 
    End If
    
    ' PERCORSO DEL DATABASE 
    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 RS = Server.CreateObject("ADODB.Recordset") 
    
    ' FA LA RICHIESTA AL DATABASE
    sql = "SELECT * FROM GuestBook_Messaggi ORDER BY " & strOrderBy &" DESC;" 
    RS.Open sql, conn, adOpenKeyset 
    RS.PageSize = iPageSize 
    
    RS.CacheSize = iPageSize 
    
    iPageCount = RS.PageCount 
    If iPageCurrent > iPageCount Then iPageCurrent = iPageCount 
    If iPageCurrent < 1 Then iPageCurrent = 1 
    
    ' NESSUN MESSAGGIO INSERITO -> VIENE VISUALIZZATO UN MESSAGGIO CHE INFORMA CHE NON E' PRESENTE
    ' NEMMENO UN MESSAGGIO NEL GUESTBOOK
    If iPageCount = 0 Then
    %><hr>
    <p align="center"><font size="2" face="Verdana">Nessun messaggio inserito nel guestbook!</font></p>
    <hr>
    <%
    Else
    
    RS.AbsolutePage = iPageCurrent 
    iRecordsShown = 0 
    
    ' SE I MESSAGGI SONO PRESENTI NEL GUESTBOOK, LI MOSTRA
    
    Do While iRecordsShown < iPageSize And Not RS.EOF 
    %>
    <hr>
    <table border="0" cellpadding="0" cellspacing="0" width="64%">
      <tr>
        <td width="28%"><font face="Verdana" size="2">Titolo Commento:</font></td>
        <td width="72%"><font face="Verdana" size="2"><%=RS("titolo")%></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Commento:</font></td>
        <td width="72%"><font face="Verdana" size="2"><%=RS("messaggio")%></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Autore:</font></td>
        <td width="72%"><font face="Verdana" size="2">"><%=RS("autore")%></font></td>
      </tr>
      <tr>
        <td width="28%"><font face="Verdana" size="2">Data inserimento:</font></td>
        <td width="72%"><font face="Verdana" size="2"><%=RS("data")%></font></td>
      </tr>
    </table>
    <hr>
    <%
    ' COMPLETA LA VISUALIZZAZIONE DEI MESSAGGI E CHIUDE LA CONNESSIONE
    ' AL DATABASE
    
    iRecordsShown = iRecordsShown + 1
    RS.MoveNext
    Loop 
    End If 
    RS.Close 
    Set RS = Nothing 
    Conn.Close
    %><center>
    <%
    ' MOSTRA IL NUMERO DELLE PAGINE
    ' DATO CHE VERRANNO MOSTRATI
    ' IN QUESTO ESEMPIO 5 MESSAGGI PER PAGINA
    
    For x=1 to iPageCount 
    %>
    <font face="Verdana" size="2">[  <%=x%> ]</font>
    <%
    next
    %>
    
    <p align="center"><font size="2" face="Verdana">Inserisci messaggio</font></p>
    
    </body>
    
    </html>
    inserisci.asp
    codice:
    <html>
    <head>
    <title>MIO GUESTBOOK</title>
    </head>
    
    <body>
    <%
    ' RICHIEDE I CAMPI DAL FORM
    titolo = Replace(Request.Form("titolo"), "'", "′")
    
    ' IMPOSTA L'INVIO A CAPO 
    '(RIMPIAZZA GLI INVII A CAPO NEL MESSAGGIO COL TAG HTML 
    ), "'", "′")
    messaggio = Replace(Replace(Request.Form("commento"), chr(13), "
    ", 1) , "'", "′")
    
    autore = Replace(Request.Form("autore"), "'", "′")
    email = Replace(Request.Form("email"), "'", "′")
    data = Date()
    
    
    ' CONTROLLO CHE I CAMPI SIANO STATI COMPILATI CORRETTAMENTE
    
    IF titolo = "" or messaggio = "" or autore = "" or Instr(email, "@") = 0 or Instr(email, ".") = 0 then
    ' UNO DEI CAMPI E' VUOTO
    %>
    <hr>
    <p align="center"><font face="Verdana" size="3">Torna indietro e compila
    tutti i campi correttamente!</font></p>
    <hr>
    <%
    ' ALTRIMENTI AGGIUNGE IL MESSAGGIO
    else
    
    ' PERCORSO DEL DATABASE 
    url_DB = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("/mdb-database/database.mdb")
    
    Set Conn = Server.CreateObject("ADODB.Connection") 
    conn.Open url_DB
    
    ' APRE LA CONNESSIONE AL DATABASE
    Set RecSet = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT * FROM GuestBook_Messaggi"
    RecSet.Open SQL, Conn, adOpenStatic, adLockOptimistic
    
    ' AGGIUNGE IL MESSAGGIO NEL DATABASE
    Recset.Addnew
    
    RecSet("titolo") = titolo
    RecSet("messaggio") = messaggio
    RecSet("autore") = autore
    RecSet("email") = email
    RecSet("data") = data
    
    ' AGGIORNA IL DATABASE, CHIUDE LA CONNESSIONE
    ' E PORTA L'UTENTE NEL GUESTBOOK
    RecSet.Update
    
    RecSet.Close
    Conn.Close
    Response.Redirect "guestbook.asp"
    end if
    %>
    </body>
    
    </html>
    volevo sapere se la soluzione nell' articolo postato e il mio guestbook possono essere integrate....e se qualche anima buona può aiutarmi un attimo a farlo..
    Grazie anticipatamente
    Saluti

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,563
    Non è consentito aprire nuove discussioni per lo stesso argomento.

    Roby

  3. #3
    Mi scuso con il forum.... ma nell'altra discussione aperta ho postato male il mio problema....sarebbe possibile chiudere l'altra discussione e lasciare aperta questa?

  4. #4
    Ti ho dato la soluzione nell'altro post

  5. #5
    Dov'è l'altro post? Io non lo trovo
    Welt

  6. #6

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 © 2024 vBulletin Solutions, Inc. All rights reserved.