Codice PHP:
<?php
function checkmail ($email)
{
if (!eregi("^[a-z0-9][_.a-z0-9-]+@([a-z0-9][0-9a-z-]+.)+([a-z]{2,4})$",$email)) return false;
else return true;
}
$nome = isset($_POST['nome']) && trim($_POST['nome']) != '' ? trim($_POST['nome']) : false;
$cognome = isset($_POST['cognome']) && trim($_POST['cognome']) != '' ? trim($_POST['cognome']) : false;
$email = isset($_POST['email']) && trim($_POST['email']) != '' ? trim($_POST['email']) : false;
if ($email && !check_mail($email)) $email = false;
echo "
<form action=\"".basename($_SERVER['PHP_SELF'])."\" method=\"post\">
nome: <input type=\"text\" name=\"nome\" value=\"$nome\"> ".($nome === false ? "<font color=red>campo obbligatorio</font>" : "")."
cognome : <input type=\"text\" name=\"cognome\" value=\"$cognome\"> ".($cognome === false ? "<font color=red>campo obbligatorio</font>" : "")."
e-mail : <input type=\"text\" name=\"email\" value=\"$email\"> ".($email === false ? "<font color=red>campo obbligatorio</font>" : "")."
<input type=\"submit\">
</form>";
?>