1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
<?php
// N'afficher que les erreurs, pas les avertissements...
ini_set("error_reporting", "E_ALL & ~E_NOTICE");
// Adresse de réception du formulaire
$email_dest = "test@test.com";
if ($_POST['envoi']) {
// E-mail headers:
$headers ="MIME-Version: 1.0 \n";
$headers .="From: visiteurs du site <test@test.com>\n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$subject = "Inscription newsletter";
$partie_entete = "<html><head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body bgcolor=#FCE1AA>";
for ($a=1; $a<= $_POST['nbre_champs_texte']; $a++)
if ($_POST['nbre_zone_email'] != 0) {
$partie_zone_email = "<font face='Verdana' size='2' color='#8e1a2c'>" . $_POST['titre_email'] . " = " . $_POST['zone_email'] . "</font><br>";
}
$fin = "</body></html>";
$sortie = $partie_entete . $partie_zone_email. $fin ;
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
// Renvoi à la page de remerciement
header("Location:thanks.html");
exit();
} // Fin du else
} // Closing if edit
?><html><head><title></title><script language="JavaScript">function verifSelection() {if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
} if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
}
invalidChars = " /:,;'"
for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (document.mail_form.zone_email.value.indexOf(badChar,0) > -1) {
alert("Invalid Character. Please check.")
document.mail_form.zone_email.focus()
return false
}
}
atPos = document.mail_form.zone_email.value.indexOf("@",1) // there must be one "@" symbol
if (atPos == -1) {
alert('Please enter "@".')
document.mail_form.zone_email.focus()
return false
}
if (document.mail_form.zone_email.value.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
alert('only one "@" symbol. Please check.')
document.mail_form.zone_email.focus()
return false
}
periodPos = document.mail_form.zone_email.value.indexOf(".",atPos)
if (periodPos == -1) { // and at least one "." after the "@"
alert('and at least one "." after the "@". Please check.')
document.mail_form.zone_email.focus()
return false
}
if (periodPos+3 > document.mail_form.zone_email.value.length) { // must be at least 2 characters after the
alert('must be at least 2 characters after the ".". Please check.')
document.mail_form.zone_email.focus()
return false
}} // Fin de la fonction
</script>
</head>
<body>
<form name="mail_form" method="post" action="forms.php" onSubmit="return verifSelection()">
<div align="center"></div>
<p align="center">
<table width="566" border="0" align="center">
<p align="center">
</p><tr>
<td width><font face="Verdana" color="8e1a2c" size="2">E mail *</font></td>
<td width><input name="zone_email" type="text"></td>
</tr><tr>
<td valign="top"><input name="nbre_champs_texte" type="hidden" id="nbre_champs_texte" value="1">
<input name="nbre_zones_texte" type="hidden" value="1">
<input name="nbre_zone_email" type="hidden" value="1">
<input name="titre_email" type="hidden" value="E mail"></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="envoi" value="Send">
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="left">
<span style="color: #8e1a2c;">
* Mandatory fields
</span>
</div>
</form></body></html> |