Dunque gente, facciamo un po di chiarezza. Nella pagina contatt.php abbiamo:
codice:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="javascript" type="text/javascript">
<!--
function Modulo() {
if ((document.modulo.nome.value == "")) {
alert("Il campo Nome è obbligatorio");
document.modulo.nome.focus();
return false;
}
else if ((document.modulo.email.value == "")) {
alert("Il campo Email è obbligatorio");
document.modulo.email.focus();
return false;
}
else if ((document.modulo.messaggio.value == "")) {
alert("Il campo Messaggio è obbligatorio");
document.modulo.messaggio.focus();
return false;
}
else {
document.modulo.action = "mailto.php";
document.modulo.submit();
}
}
//-->
</script>
e
codice:
<form method="post" name="modulo" action="mailto.php">
<fieldset id="informazioni">
<legend>Informazioni Generali</legend>
<label for="nome">Nome e cognome:</label><input type="text" name="nome" id="nome" value="" tabindex="1" accesskey="n" /></p>
<label for="email">Email:</label><input type="text" name="email" id="email" value="" tabindex="2" accesskey="c" /></p>
<label for="oggetto">Oggetto:</label><input type="text" name="oggetto" id="oggetto" value="" tabindex="3" accesskey="o" /></p>
<label for="message">Messaggio:</label><textarea name="message" cols="20" rows="7" id="message" tabindex="4" accesskey="m"></textarea></p>
</fieldset>
<fieldset id="conferma">
<legend>Conferma e invio dei dati</legend>
<input name="submit" type="submit" id="invia" tabindex="5" accesskey="I" value="Invia" onClick="Modulo();return()"/>
<input id="annulla" type="reset" value="Riscrivi" tabindex="6" accesskey="r"/>
</fieldset>
</form>
Nella pagina mailto.php abbiamo invece:
codice:
<?php
//varie info per email
$oggi = date("j F Y G:i");
$sito = "www.carmelomodica.it";
$ip = "$_SERVER[REMOTE_ADDR]";
$browser = "$_SERVER[HTTP_USER_AGENT]";
$to = "modica.c@tiscali.it";
$soggetto = "Modulo da $sito";
if(trim($_POST['nome']) == "" OR trim($_POST['messaggio']) == ""){
echo "<font color=\"#FF0000\" face=\"verdana\" size=\"2\">Tutti i campi sono obbligatori</font>";
} else {
$body = "Modulo inviato il $oggi da $ip - $browser \n\n";
$body .= "Nome: $_POST[nome] \nEmail: $_POST[email] \nMessaggio: $_POST[messaggio]";
mail("$to","$soggetto","$body");
?>
codice:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="javascript" type="text/javascript">
<!--
function Modulo() {
if ((document.modulo.nome.value == "")) {
alert("Il campo Nome è obbligatorio");
document.modulo.nome.focus();
return false;
}
else if ((document.modulo.email.value == "")) {
alert("Il campo Email è obbligatorio");
document.modulo.email.focus();
return false;
}
else if ((document.modulo.messaggio.value == "")) {
alert("Il campo Messaggio è obbligatorio");
document.modulo.messaggio.focus();
return false;
}
else {
document.modulo.action = "mailto.php";
document.modulo.submit();
}
}
//-->
</script>