Il file aggiungi.asp modificalo in questo modo
<%
Dim max_num
max_num = 3
Randomize()
Session("captcha") = CInt((max_num - 1) * Rnd() + 1)
%>
<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="28%"><font face="Verdana" size="2">Codice di Sicurezza:</font></td>
<td width="72%"><font face="Verdana" size="2"> <input type="text" name="codice">
[img]<%=Session([/img].gif" align="absmiddle"></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>
mentre modificherai il file inserisci .asp in questo modo:
<html>
<head>
<title>MIO GUESTBOOK</title>
</head>
<body>
<%
Dim codice, controllo
codice = Request.Form("codice")
Select Case Session("captcha")
Case "1" : controllo = "ABC"
Case "2" : controllo = "BCA"
Case "3" : controllo = "CBA"
End Select
if codice <> controllo Then
%>
Inserire il codice di sicurezza!</p>
Torna indietro</p>
<%
Else
' 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
End If
%>
</body>
</html>
naturalmente le tre immagini gif dovranno essere inserite nella stessa cartella del guestbook
ciao