richiamando tale funzione:
<script language="JavaScript">
function controlla(){
var nome=document.scheda.nome.value;
var cognome=document.scheda.cognome.value;
var indirizzo=document.scheda.indirizzo.value;
var info=document.scheda.info.value;
var email=document.scheda.email.value;
var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
if (nome==""){
alert("Il campo nome è obbligatorio!");
return false;
}
if (cognome==""){
alert("Il campo cognome è obbligatorio!");
return false;
}
if (indirizzo==""){
alert("Il campo indirizzo è obbligatorio!");
return false;
}
if (email==""){
alert("Il campo e-mail è obbligatorio!");
return false;
}
else{
if (!email_reg_exp.test(email)){
alert("Inserisci un indirizzo e-mail corretto!");
return false;
}
}
if (info==""){
alert("Il campo informazioni è obbligatorio!");
return false;
}
//document.scheda.action = "sendMail.php";
document.scheda.submit();
window.open('sendMail.php','Promez_Invio_mail','wi dth=420,height=300,status=no');
}
</script>
nella pagina sendmail.php non riesco ad avere i valori del form presente nella pagina nella quale si trova la funzione su scritta.
Il metodo usato e' il POST.
Eccovi il listato di sendmail.php:
<?
# l'indirizzo email a cui inviare la mail
$target="an_aurora@libero.it";
$subject="Invio mail dal sito www.promez.it";
$message="Nome: ".$HTTP_POST_VARS['nome']."\nCognome: ".$HTTP_POST_VARS['cognome']."\nIndirizzo: ".$HTTP_POST_VARS['indirizzo'];
if(!empty($HTTP_POST_VARS['citta']))
$message=$message."\nCittà: ".$HTTP_POST_VARS['citta'];
if(!empty($HTTP_POST_VARS['provincia']))
$message=$message."\nProvincia: ".$HTTP_POST_VARS['provincia'];
if(!empty($HTTP_POST_VARS['attivita']))
$message=$message."\nAttività di interesse: ".$HTTP_POST_VARS['attivita'];
$message=$message."Richiede informzioni su: ".$HTTP_POST_VARS['info'];
print_r($message);
mail($target,$subject,$message,"From:".$HTTP_POST_ VARS['email']);
echo"<html><head>
<title>Promez - Invio e-mail</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<link rel=\"stylesheet\" href=\"css/promez.css\" type=\"text/css\">
</head><body>";
echo "<table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td width=\"210\" rowspan=\"2\"><img src=\"images/logo_promez.gif\" width=\"210\" height=\"57\"></td>
<td height=\"19\" width=\"550\" align=\"left\"><img src=\"images/spot.gif\" width=\"155\" height=\"19\"></td>
</tr>
<tr>
<td background=\"images/fondo_barra.gif\" height=\"38\" align=\"left\" valign=\"top\" width=\"550\"></td>
</tr>
</table>
";
echo "<div align=\"center\">E-mail inviata correttamente!
Il nostro staff vi risponderà al più presto.</div>
";
echo "<table width=\"400\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td height=\"1\" bgcolor=\"#091A4D\" colspan=\"3\"></td>
</tr>
<tr>
<td height=\"29\" bgcolor=\"D4D8E4\" width=\"210\"></td>
<td height=\"29\" bgcolor=\"EAECF2\" width=\"171\" align=\"right\"></td>
<td height=\"29\" bgcolor=\"EAECF2\" width=\"380\"></td>
</tr>
<tr>
<td height=\"1\" bgcolor=\"#091A4D\" colspan=\"3\"></td>
</tr>
</table>";
echo "</body></html>";
?>