bonjour a tous
je vous fais parvenir deux codes
1. celui du formulaire
2. le traitement
1
Code html :
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
| <html>
<head>
</head><body bgcolor="#33FF66">
<div align=center>
<form action=traitement.php method=POST>
<p>
<input type=hidden name=subject value=formmail>
</p>
<p><strong><font color="#FFFFFF" size="4">Formulaire de demande de renseignements</font></strong></p>
<table width="627" border="1" bordercolor="#00CC00" bgcolor="#33FF99">
<tr>
<td height="26"><div align="center"><em><strong>Votre nom :</strong></em></div></td>
<td> <div align="center">
<input type=text name=nom size=30>
</div></td>
</tr>
<tr>
<td width="305" height="26"><div align="center"><em><strong>Votre Prénom
:</strong></em></div></td>
<td width="275"> <div align="center">
<input type=text name=prenom size=30>
</div></td>
</tr>
<tr>
<td height="28"><div align="center"><em><strong>Votre Adresse</strong></em></div></td>
<td> <div align="center">
<textarea name="adresse" cols="30" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td bordercolor="#993366"><div align="center"><em><strong>Votre numéro
de téléphone : </strong></em></div></td>
<td bordercolor="#993366"> <div align="center">
<input type=text name=telephone size=30>
</div></td>
</tr>
<tr>
<td bordercolor="#993366"><div align="center"><em><strong>Votre Email
:</strong></em></div></td>
<td bordercolor="#993366"> <div align="center">
<input type=text name=email size=30>
</div></td>
</tr>
<tr>
<td bordercolor="#993366"><div align="center"><em><strong>Sujet :</strong></em></div></td>
<td bordercolor="#993366"> <div align="center">
<select name="situation">
<option>Demande de reseignements</option>
<option>Demande d'inscription</option>
<option>Demande de rendez-vous</option>
<option>Autres</option>
</select>
</div></td>
</tr>
<tr>
<td bordercolor="#993366"> <div align="center"><em><strong>Vous êtes
:</strong></em></div></td>
<td bordercolor="#993366"> <div align="center">
<select name="select">
<option>Sans emploi</option>
<option>Etudiant</option>
<option>Salarié</option>
<option>Une entreprise</option>
<option>Autres...</option>
</select>
</div></td>
</tr>
<tr>
<td height="23" bordercolor="#993366"><div align="center"><em><strong>Votre
secteur d'activité : </strong></em></div></td>
<td height="23" bordercolor="#993366"><div align="center">
<select name="secteur">
<option>Paysage -Espace Vert</option>
<option>Agriculture</option>
<option>Agro-Alimentaire</option>
<option>Mécanique & Maintenance Agricole</option>
<option>Autres...</option>
</select>
</div></td>
</tr>
<tr>
<td height="60" colspan=2 bordercolor="#993366"><table width="586" border="1">
<tr>
<td width="576"><div align="center"><strong><em>Vos commentaires
:</em></strong></div></td>
</tr>
<tr>
<td> <div align="center">
<textarea name="commentaire" cols="50" rows="5"></textarea>
</div></td>
</tr>
</table>
<div align="center"></div></td>
</tr>
</table>
<p>
<input type=submit value=Envoyer>
-
<input type=reset value=Annuler>
</p>
</form>
</div>
</body>
</html> |
2
Code :
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
| <?php
$msg_erreur = "Erreur. Les champs suivants doivent être obligatoirement remplis :<br/><br/>";
$msg_ok = "Votre demande a bien été prise en compte.";
$message = $msg_erreur;
// vérification des champs if (empty($_POST['nom']))
$message .= "Votre nom<br/>";
if (empty($_POST['adresse']))
$message .= "Votre adresse<br/>";
if (empty($_POST['codepostal']))
$message .= "Votre code postal<br/>";
if (empty($_POST['ville']))
$message .= "Votre ville<br/>";
if (empty($_POST['comments']))
$message .= "Vos comentaires<br/>";
if ($_POST['situation']=='null')
$message .= "Votre situation<br/>";
// si un champ est vide, on affiche le message d'erreur
if (strlen($message) > strlen($msg_erreur)) {
echo $message;
// sinon c'est ok
}
else {
echo $msg_ok;
mail('xxxxxxxxxxxxxx@educagri.fr','formulaire du site');//comment indiquer que l'on veut récupérer les champs????
}
?> |
pouvez-vous svp m'expliquer comment dans le cas ou mon message est prêt a partir quelle est la syntaxe pour récupérer les valeurs du formulaire
merci