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 127
| <?php
function formulaire($Nom="Nom",$Telephone="Telephone",$Codepostal="Code postal",$Ville="Ville",$Rue="Rue",$Email="@mail",$Message="Votre message")
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0" class="tour" cellspacing="0" cellpadding="5" align="center" width="543">
<tr class="unite">
<td width="19%" >Nom :</td>
<td width="81%">
<input type="text" name="Nom" size="30" value="<?php echo trim(htmlentities($Nom)) ?>" />
</td>
</tr>
<tr class="unite">
<td width="19%">Rue :</td>
<td width="81%">
<input type="text" name="Rue" size="40" value="<?php echo trim(htmlentities($Rue)) ?>" />
</td>
</tr>
<tr class="unite">
<td width="19%">Code Postal :</td>
<td width="81%">
<input type="text" name="Codepostal" size="5" value="<?php if (isset($Codepostal))echo trim(htmlentities($Codepostal)); ?>" />
</td>
</tr>
<tr class="unite">
<td width="19%">Ville :</td>
<td width="81%">
<input type="text" name="Ville" size="40" value="<?php echo trim(htmlentities($Ville)) ?>" />
</td>
</tr>
<tr class="unite">
<td width="19%">Téléphone :</td>
<td width="81%">
<input type="text" name="Telephone" value="<?php echo trim(htmlentities($Telephone)) ?>" size="15" maxlength="10" />
</td>
</tr>
<tr class="unite">
<td width="19%">E-mail :</td>
<td width="81%">
<input type="text" name="Email" value="<?php echo trim(htmlentities($Email)) ?>" size="30" />
</td>
</tr>
<tr class="unite">
<td valign="top" width="19%">Message :</td>
<td width="81%">
<textarea name="Message" alt="Message" rows="10" cols="45" wrap="virtual"><?php if (ereg("[]%~#`$&|}{^[><]",$Message)) { echo "Certains caractères utilisés sont interdits";
$erreur=true; }
else {echo trim($Message); } ?></textarea>
</td>
</tr>
<tr class="unite">
<td width="19%"> </td>
<td width="81%">
<center>
<br />
<input type="submit" name="Submit" value="Envoi" alt="Envoi" title="Envoi de votre message" onmouseover="this.style.color='#ff0000'" onmouseout="this.style.color='#000000'" onmousedown="this.style.color='#ff9900'" />
</center>
</td>
</tr>
</table>
<?php
}
if(!isset($Nom))
{
formulaire();
}
else
{
$vNom=trim(htmlentities($_POST["Nom"]));
$vRue=trim(htmlentities($_POST["Rue"]));
$vCodepostal=trim(htmlentities($_POST["Codepostal"]));
$vVille=trim(htmlentities($_POST["Ville"]));
$vTelephone=trim(htmlentities($_POST["Telephone"]));
$vMessage=trim($_POST["Message"]);
$vEmail=trim(htmlentities($_POST["Email"]));
$destinataire='exemple@exemple.fr';
$titre="Modèle de page Contact";
$message="Provenance : $HTTP_REFERER\n";
$message.="Adresse IP : $REMOTE_ADDR,\n";
$message.="Navigateur : $HTTP_USER_AGENT\n";
$message.="Nom : $vNom\n";
$message.="Rue : $vRue\n";
$message.="Code postal : $vCodepostal\n";
$message.="Ville : $vVille\n";
$message.="Telephone : $vTelephone\n";
$message.="E-mail : $vEmail\n";
$message.="Message : $vMessage\n";
if (empty($vNom) || empty($Message) || empty($Email))
{
echo "<p class='red'>Vous n'avez pas complété toutes les zones :</p>";
$erreur=true;
}
if (!preg_match("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-_.]?[0-9a-z])*\\.[a-z]{2,4}$",$vEmail) && ($erreur<>1))
{
echo "<p class='red'>L'adresse e-mail n'est pas correcte :</p>";
$erreur=true;
}
if ($erreur)
{
formulaire($Nom,$Telephone,$Rue,$Codepostal,$Ville,$Email,$Message);
}
else
{
mail($destinataire,$titre,$message,"From: $vEmail") ;
echo "<p class='vi4'>Votre message :</p>";
echo "<ul><li>Nom : <span class='red'>" . $vNom . "</span><br />";
echo "<li>Rue : <span class='red'>" . $vRue. "</span></li>";
echo "<li>Code postal : <span class='red'>" . $vCodepostal. "</span></li>";
echo "<li>Ville : <span class='red'>" . $vVille. "</span></li>";
echo "<li>Telephone : <span class='red'>" . $vTelephone. "</span></li>";
echo "<li>E-mail : <span class='red'>" . $vEmail. "</span></li>";
echo "<li>Message : <span class='red'>" . $vMessage.'</span></li></ul>';
echo "<p class='vi4'>Votre message a bien été envoyé. Nous vous remercions.</p>\n" ;
echo "<form name='boutons'><table border='0' cellspacing='0' cellpadding='0' width='90%' align='center'><tr><td><center>" ;
echo "<input type='button' name='accueil' alt='Accueil' value=\"Retour à la page d'accueil\" style='color:#660066;background-color:#ebe7f1' onclick=\"location.href='index.htm'\" onmouseover=\"this.style.color='#ff0000'\" onmouseout=\"this.style.color='#660066'\" onmousedown=\"this.style.color='#ff9900'\" />\n";
echo "</center></td></tr></table>";
}
}
?>
</form>
</body>
</html> |
Partager