Bonjour,
Voici un formulaire simple, je voudrais simplement rendre tous les champs obligatoire (sauf le champs société)
Code présent sur la page de contact html :
<table width="616" border="0" align="left" cellpadding="0" cellspacing="0">
<form action="contact.php" method="post" enctype="application/x-www-form-urlencoded" name="formulaire">
<tr>
<td class="content"><div align="left">Votre Nom :</div></td>
<td colspan="2"><input type="text" name="nom" size="45" maxlength="100"></td>
</tr>
<tr>
<td width="17%" class="content"><div align="left">Votre Prénom :</div></td>
<td colspan="2"><input type="text" name="prenom" size="45" maxlength="100"></td>
</tr>
<tr>
<td width="17%" class="content"><div align="left">Société :</div></td>
<td colspan="2"><input type="text" name="societe" size="45" maxlength="100">
(facultatif)</td>
</tr>
<tr>
<td height="22" class="content"><div align="left">Votre Email : </div></td>
<td colspan="2"><input type="text" name="email" size="45" maxlength="120"></td>
</tr>
<td class="content"><div align="left">Votre message : </div></td>
<td colspan="2"><textarea name="message" cols="45" rows="3"></textarea>
<br></td>
</tr>
<tr>
<td height="53"></td>
<td width="41%"><input name="Submit" type="submit" class="content" value="Envoyer"></td>
</tr>
Code présent dans le fichier contact.php :
<?php
$nom=$HTTP_POST_VARS['nom'];
$prenom=$HTTP_POST_VARS['prenom'];
$societe=$HTTP_POST_VARS['societe'];
$email=$HTTP_POST_VARS['email'];
$message=$HTTP_POST_VARS['message'];
/////voici la version Mine
$headers = "MIME-Version: 1.0\r\n";
//////ici on détermine le mail en format text
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
////ici on détermine l'expediteur et l'adresse de réponse
$headers .= "From: $nom <$email>\r\nReply-to : $nom <$email>\nX-Mailer:PHP";
$subject="Message de $nom $prenom";
$destinataire="mon adresse email";
$body="
Nom : $nom
Prénom : $prenom
Société : $societe
Email : $email
Message : $message";
if (mail($destinataire,$subject,$body,$headers)) {
echo "Votre message a été transmis avec succès<br>";
} else {
echo "Une erreur s'est produite";
}
?></p>
<p align="center">Vous allez bientot être redirigé vers la page d’accueil du Site.<br>
Si vous n'êtes pas redirigé au bout de 5 secondes cliquez <a href="<a href="http://www.message-envoye.com/" target="_blank">http://www.message-envoye.com/</a>">ici
</a></p>
Merci bien.