codice:
<html>
<head>
<title>My guestbook</title>
</head>
<body>
<%
' RICHIEDE I CAMPI DAL FORM
nome = Replace(Request.Form("nome"), "'", "")
cognome = Replace(Request.Form("cognome"), "'", "")
citta = Replace(Request.Form("citta"), "'", "")
datadinascita = Replace(Request.Form("datadinascita"), "'", "")
nazione = Replace(Request.Form("nazione"), "'", "")
url = Replace(Request.Form("url"), "'", "")
commento = Replace(Request.Form("commento"), "'", "")
piatto= Replace(Request.Form("piatto"), "'", "")
sogno = Replace(Request.Form("sogno"), "'", "")
fare40anni = Replace(Request.Form("fare40anni"), "'", "")
' IMPOSTA L'INVIO A CAPO
'(RIMPIAZZA GLI INVII A CAPO NEL MESSAGGIO COL TAG HTML
), "'", "")
fanculo = Replace(Replace(Request.Form("fanculo"), chr(13), "
", 1) , "'", "")
email = Replace(Request.Form("email"), "'", "")
hardcore1 = Replace(Request.Form("hardcore1"), "'", "")
hardcore2 = Replace(Request.Form("hardcore2"), "'", "")
hardcore3 = Replace(Request.Form("hardcore3"), "'", "")
data = Date()
' CONTROLLO CHE I CAMPI SIANO STATI COMPILATI CORRETTAMENTE
IF nome = "" or cognome = "" or fanculo = "" or hardcore1 = ""or hardcore2 = "" 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("nome") = nome
RecSet("cognome") = cognome
RecSet("citta") = citta
RecSet("datadinascita") = datadinascita
RecSet("nazione") = nazione
RecSet("email") = email
RecSet("url") = url
RecSet("commento") = commento
RecSet("piatto") = piatto
RecSet("fare40anni") = fare40anni
RecSet("sogno") = sogno
RecSet("data") = data
RecSet("fanculo") = fanculo
RecSet("hardcore1") = hardcore1
RecSet("hardcore2") = hardcore2
RecSet("hardcore3") = hardcore3
' 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>