par
miiidooo19 » 06 févr. 2012, 17:38
ok bon la voila ce que j'ai fait je pense que c'est correct a vous de me corriger
avant de passer au code je voulais savoir maintent ds formulaire <form action je met quel lien ? lien vers contrôleur?
voici le code : contrôleur
require_once MODELS.'catalogue.php';
if(isset($_POST['valider']))
{
$msg = SendMail($_POST['nom'],$_POST['prenom'],$_POST['mail'],$_POST['tel']);
$smarty->assign('msg', $msg);
}
modele :
function SendMail($nom,$prenom,$mail,$tel)
{
$msg = '';
if (($nom == '') or ($prenom == '') or ($mail == ''))
$msg ='<center><span style="color:red; font-weight:blod;"> Votre formulaire est invalide merci de remplire les champs obligatoires</span><center><br />';
else{
if ($tel == '')
$tel ='Non précisé';
/* Ici envoie l mail à infos@eco-poules
déclaration des paramètres de la fonction mail
*/
if(mail($to,$sujet,$contenu,$headers))
$msg ='<center><span style="color:green; font-weight:blod;">Votre demande a bien été envoyé, elle sera traité dans les plus bref délais. Merci pour votre compréhension</span><center><br /> ';
else
$msg = 'Votre demande n\'a pas été envoyé, merci d\'essayer plutard';
}
return $msg;
}
Vue :
<br/><br/><br/>
<center>
<div id="catalogue">
<span style="font-weight:bold;">Veuillez remplir les champs suivants :</span><br /><br />
<!--{$msg}-->
<form method="POST" action="./catalogue.html" >
<table >
<tr>
<td>Nom <span style="color:red;">*</span></td><td> <input type="text" name="nom" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Prénom <span style="color:red;">*</span></td><td> <input type="text" name="prenom" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Adresse Mail <span style="color:red;">*</span></td><td> <input type="text" name="mail" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Tèl </td><td> <input type="text" name="tel" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td></td><td> <input type="submit" name="valide" value="Je demande un catalogue Eco-poule" style="font-weight : bold; color:green;background-color:#fda13f;height:35px;"/></td>
</tr>
</table>
</form>
</div>
</center>
ok bon la voila ce que j'ai fait je pense que c'est correct a vous de me corriger
avant de passer au code je voulais savoir maintent ds formulaire <form action je met quel lien ? lien vers contrôleur?
voici le code : contrôleur
[php]require_once MODELS.'catalogue.php';
if(isset($_POST['valider']))
{
$msg = SendMail($_POST['nom'],$_POST['prenom'],$_POST['mail'],$_POST['tel']);
$smarty->assign('msg', $msg);
}[/php]
modele :
[php]function SendMail($nom,$prenom,$mail,$tel)
{
$msg = '';
if (($nom == '') or ($prenom == '') or ($mail == ''))
$msg ='<center><span style="color:red; font-weight:blod;"> Votre formulaire est invalide merci de remplire les champs obligatoires</span><center><br />';
else{
if ($tel == '')
$tel ='Non précisé';
/* Ici envoie l mail à infos@eco-poules
déclaration des paramètres de la fonction mail
*/
if(mail($to,$sujet,$contenu,$headers))
$msg ='<center><span style="color:green; font-weight:blod;">Votre demande a bien été envoyé, elle sera traité dans les plus bref délais. Merci pour votre compréhension</span><center><br /> ';
else
$msg = 'Votre demande n\'a pas été envoyé, merci d\'essayer plutard';
}
return $msg;
}[/php]
Vue :
[html]<br/><br/><br/>
<center>
<div id="catalogue">
<span style="font-weight:bold;">Veuillez remplir les champs suivants :</span><br /><br />
<!--{$msg}-->
<form method="POST" action="./catalogue.html" >
<table >
<tr>
<td>Nom <span style="color:red;">*</span></td><td> <input type="text" name="nom" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Prénom <span style="color:red;">*</span></td><td> <input type="text" name="prenom" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Adresse Mail <span style="color:red;">*</span></td><td> <input type="text" name="mail" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td>Tèl </td><td> <input type="text" name="tel" style="background-color:#e4f9d5;"/></td>
</tr>
<tr>
<td></td><td> <input type="submit" name="valide" value="Je demande un catalogue Eco-poule" style="font-weight : bold; color:green;background-color:#fda13f;height:35px;"/></td>
</tr>
</table>
</form>
</div>
</center>[/html]