Esempio:
form.html
codice:
<html>
<head>
<title>Titolo Pagina</title>
</head>
<body>
<form method="post" action="pagina.asp">
<label for="nome">nome * </label> <input type="text" name="nome" id="nome" /></p>
<label for="cognome">cognome </label> <input type="text" name="cognome" id="cognome" /></p>
<label for="email">email * </label> <input type="text" name="email" id="email" /></p>
<label for="legge">Legge sulla privacy</label><textarea cols="20" rows="5" name="legge" id="legge" readonly="readonly">Il Dlg eccetera, eccetera...</textarea></p>
<label for="privacy">Accetto il trattamento dei dati * </label><input type="checkbox" name="privacy" id="privacy" value="1" /></p>
<input type="submit" value="INVIA" /></p>
I campi con asterisco * sono obbligatori.
</form>
</body>
</html>
pagina.asp
codice:
<%
erroreCampi = false
nome = trim(request.form("nome"))
cognome = trim(request.form("cognome"))
email = trim(request.form("email"))
privacy = trim(request.form("privacy"))
messaggioErrore = "Attenzione:
"
if len(nome) = 0 then
erroreCampi = true
messaggioErrore = messaggioErrore & "Il campo nome è obbligatorio;
"
end if
if len(email) = 0 then
erroreCampi = true
messaggioErrore = messaggioErrore & "Il campo email è obbligatorio;
"
end if
if len(privacy) > 0 and isNumeric(privacy) then
privacy = cLng(privacy)
else
privacy = 0
end if
if privacy <> 1 then
erroreCampi = true
messaggioErrore = messaggioErrore & "È necessario accettare il trattamento dei dati;
"
end if
if not erroreCampi then
' qui processi i dati presi dalla form a tuo piacimento
end if
%>
<html>
<head>
<title>Titolo Pagina</title>
</head>
<body>
<%
if erroreCampi then
response.write messaggioErrore
else
response.write "Operazione eseguita."
end if
%>
</body>
</html>
Se non comprendi questo, la vedo dura...