Bonjour
je débute complètement et bien entendu je veux un formulaire bien trop complexe pour moi...
j'ai réussi à faire un formulaire simple avec que des zones de texte, ça marche (sauf message de validation soue IE, c'est ok sous ff)
le nouveau formulaire est celui là:
- des champs texte simple
- un champ avec menu déroulant pour un seul choix
- 4 champ parcourir pour uploader 4 image (que je voudrais recevoir par mail en piece jointe)
il me semble avoir bien fait la partie html... mais alors la partie PHP (et je n'y connais rien) c'est le gros bazard... je te colle des bouts de ci des morceaux de ça.... je n'ai pas réussi à trouver un tuto qui prend en compte ses trois parametres cités ci dessus.
quelqu'un aurait il un peu de temps à me donner pour me faire marcher ce machin ou m'envoyer vers un totu qui prend en compte tes ses parametres.
par avance un grand merci à celui/celle qui 'aidera
voici le html
Et la partie php
je débute complètement et bien entendu je veux un formulaire bien trop complexe pour moi...
j'ai réussi à faire un formulaire simple avec que des zones de texte, ça marche (sauf message de validation soue IE, c'est ok sous ff)
le nouveau formulaire est celui là:
- des champs texte simple
- un champ avec menu déroulant pour un seul choix
- 4 champ parcourir pour uploader 4 image (que je voudrais recevoir par mail en piece jointe)
il me semble avoir bien fait la partie html... mais alors la partie PHP (et je n'y connais rien) c'est le gros bazard... je te colle des bouts de ci des morceaux de ça.... je n'ai pas réussi à trouver un tuto qui prend en compte ses trois parametres cités ci dessus.
quelqu'un aurait il un peu de temps à me donner pour me faire marcher ce machin ou m'envoyer vers un totu qui prend en compte tes ses parametres.
par avance un grand merci à celui/celle qui 'aidera
voici le html
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="formule_complete.php">
<div align="center">
<table width="47%" >
<tr>
<td width="47%">Titre - Accroche*</td>
<td width="53%"><input name="titre" type="text" size="50" class="fond" /></td>
</tr>
<tr>
<td>Activité*</td>
<td><input name="activite" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Nom*</td>
<td><input name="nom" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Prenom*</td>
<td><input name="prenom" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Mail*</td>
<td><input name="mail" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Adresse*</td>
<td><input name="adresse" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Code postal*</td>
<td><input name="code_postal" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Ville*</td>
<td><input name="ville" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Téléphone*</td>
<td><input name="tel" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Portable*</td>
<td><input name="port" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Site web*</td>
<td><input name="site_web" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Gamme de prix* ( - et +)</td>
<td><input name="gamme_prix" type="text" size="50" class="fond"/></td>
</tr>
<tr>
<td>Zone géographique couverte</td>
<td><label>
<select name="zone_activite" class="fond" id="zone activité">
onChange="chgpage(this.form)">
<option selected="selected">Choix de la zone </option>
<option value="no">Nord Ouest </option>
<option value="ne">Nord Est</option>
<option value="idf">Ile de France</option>
<option value="se">Sud Est</option>
<option value="so">Sud Ouest</option>
</select>
</label></td>
</tr>
<tr>
<td>Vignette <span class="Style21">(largeur 160px)</span>*</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" height="600" width="600"><input name="fichier" type="file" size="35" class="fond" accept="image/jpg"></td>
</tr>
<tr>
<td>Image 1 <span class="Style21">(largeur ou hauteur max 600px)</span><span class="Style3">*</span></td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" height="600" width="600"><input name="fichier" type="file" size="35" class="fond" accept="image/jpg"></td>
</tr>
<tr>
<td>Image 2 <span class="Style21">(largeur ou hauteur max 600px)</span>*</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" height="600" width="600"><input name="fichier" type="file" size="35" class="fond" accept="image/jpg"></td>
</tr>
<tr>
<td>Image 3 <span class="Style21">(largeur ou hauteur max 600px)</span>*</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" height="600" width="600"><input name="fichier" type="file" size="35" class="fond" accept="image/jpg"></td>
</tr>
<tr>
<td height="144" colspan="2">
<div align="center">
<textarea name="description" cols="74" rows="4" class="fond" onkeyup="textLimit(this, 300);">Description</textarea>
<br />
<div align="right"><span class="Style21">*Tous les champs obligatoires </span>
<input type="submit" value="Envoyer"/>
</div>
</div></td>
</tr>
</table>
</div>
</form>
Et la partie php
<?php // récupération des variables
// donné un autre nom au variable pour évité les problèmes avec Register Global à ON
$formTitre = $_POST['titre'];
$formActivite = $_POST['activite'];
$formNom = $_POST['nom'];
$formPrenom = $_POST['prenom'];
$formMail = $_POST['mail'];
$formAdresse = $_POST['adresse'];
$formCode_postal = $_POST['code_postal'];
$formville = $_POST['ville'];
$formTelephone = $_POST['tel'];
$formPortable = $_POST['port'];
$formSite_web = $_POST['site_web'];
$formGamme_de_prix = $_POST['gamme_prix'];
$formZone_activite = $_POST['zone_activite'];
$formFichier = $_FILES['fichier'];
$formDescription = $_POST['description'];
if (isset($_FILES['image']))
{
//$_FILES existe
foreach ($_FILES['fichier']['name'] as $key => $value) {
$fichier=$value;//nom reel de l'image
$size=$_FILES['fichier']['size'][$key]; //poids de l'image en octets
$tmp=$_FILES['fichier']['tmp_name'][$key];//nom temporaire de l'image (sur le serveur)
$type=$_FILES['fichier']['type'][$key];//type de l'image
//On récupère la taille de l'image
list($width,$height)=getimagesize($tmp);
if (is_uploaded_file($tmp)) //permet de vérifier si le fichier a été uplodé via http
{
//vérification du type de l'img, son poids et sa taille
if ($type=="image/pjg" && $size<=100000 && $width<=600 && $height<=600 )
{
// type mime gif, poids < à 20500 octets soit environ 20Ko, largeur = hauteur = 100px
//Pour supprimer les espaces dans les noms de fichiers car celà entraîne une erreur lorsque vous voulez l'afficher
$fichier = preg_replace ("` `i","",$fichier);//ligne facultative [smile]
//On vérifie s'il existe une image qui a le même nom dans le répertoire
if (file_exists('./images_up/'.$fichier))
{
//Le fichier existe on rajoute dans son nom le timestamp du moment pour le différencier de la première (comme cela on est sûr de ne pas avoir 2 images avec le même nom [smile] )
$nom_final= preg_replace("`.jpg`is",date("U").".jpg",$fichier);
}
else {
$nom_final=$fichier; //l'image n'existe pas on garde le même nom
}
//on déplace l'image dans le répertoire final
if (move_uploaded_file($tmp,'./images_up/'.$nom_final)) {
//Message indiquant que tout s'est bien passé
//Pour le test on affiche l'image
echo '<img src="./images_up/'.$nom_final.'" border="0" />';
echo '<br/>';
}
else {
//l'image ne peut être déplacée, on supprime le fichier temporaire
@ unlink ($tmp);
echo 'L\'image n\'a pu être déplacée !';
}
}
else {
//Le type mime, ou la taille ou le poids est incorrect
echo 'Votre image a été rejetée (poids, taille ou type incorrect)';
}
}
}
}
echo '<a href="javascript:history.back();">Retour</a>';
// pour éviter des erreurs de Notice dans le cas ou le champs est resté vide, on aurait pu mettre !
// $formMail = (!isset($_POST['mail']))?$_POST['mail']:'none';
// Dans le cas ou les variables sont destiné à allimenter un base de donné il faut toujours valider les valeurs pour éviter les problèmes d'injection ! cf Google
//En règle général on traite les variables avec les fonctions htmlentities, mysql_escape_string(),addslash() ...
// Dans l'exemple on va juste vérifier que le nom, le prenom et le mail soit pas vide.
if(!empty($formTitre) && !empty($formActivite) && !empty($formNom) && !empty($formPrenom) && !empty($formMail) && !empty($formAdresse) && !empty($formCode_Postal) && !empty($formVille) && !empty($formTelephone) &&!empty($formPortable) &&!empty($formSite_web) &&!empty($formGamme_prix) &&!empty ($formZone_activite) && !empty($Fichier) ){
//ok pas vide //on convertie les caractètres HTML du commentaire
$formDescription = htmlentities($formDescription);
//mise en forme du mail
$message = "$formNom $formPrenom soumet son inscription à l'annuaire -Formule complete- de l'espace mariage.\n \n ";
// on envois le mail [url=http://fr.php.net/manual/fr/ref.mail.php]http://fr.php.net/manual/fr/ref.mail.php[/url] // bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
// ATTENTION en général vous n'avez pas de serveur de mail sur votre machine !
// à tester sur le net directment en cas de problème avec la fonction mail
if( mail('contact@sokebana.net','Nouvelle inscription -Formule complète- de l\'Espace Mariage',$message. "\n Activité:" .$formActivite. "\n Titre:".$formTitre. "\n Site web:" .$formSite_web. "\n Gamme de prix:" .$formGamme_prix. "\n \n Mail:" .$formMail "\n Adresse:".$formAdresse. "\n Code postal:".$formCode_postal. "\n Ville:".$formVille. "\n Telephone:".$formTelephone. "\n Portable".$formPortable. "\n Zone couverte".$formZone_activite. "\n fichier".$formFichier."\n \n Vignette:".$formFichier." \n" )" Description: " $formDescription"\n" ){
echo ('<title>Votre soumission est prise en compte</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-repeat: no-repeat;
background:#321c0b;
color:#FFFFDD;
font-size:12px;
font-family:Verdana;
background-image: url(../photos-espace-mariage/fond-mariage.jpg);
}
a:link { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:hover { color:#ffffdd; text-decoration:none; font-weight:bold; }
a:visited { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:active { color:#0CBFDF; text-decoration:none; font-weight:bold; }
.Style3 {font-size: 12px}
.Style6 {font-size: 16px}
.Style15 {color: #0CBFDF}
.Style17 {font-size: 14px;color: #0CBFDF;}
.Style16 {font-size: 16px;color: #0CBFDF; }
.Style13 {font-size: 16px; color: #0CBFDF; font-weight:bold;}
.Style9 {font-family: "BernhardFashion BT";font-size: 23px;font-weight: bold;color: #0CBFDF;}
.Style11 {font-family: "BernhardFashion BT";font-size: 30px;color: #0cbfdf;font-weight:bold;}
.Style14 {font-family: "BernhardFashion BT";font-size: 30px;}
.container {
width: 500px; /*largeur menu*/
padding: 5px;
margin: 0px 0 0px 0; /* 1ere valeur = marge depuis le top*/
background: #321D0C; /* fond du menu*/
}
div#menu
{
padding:fixed;
margin-top:0px;
}
div#entete
{
padding:fixed;
margin-top:0px;
}
/* circle */
#navCircle {
margin: 0;
padding: 0 0 23px 20px; /* valeur à 20 = espace entre menu et ligne bleue*/
border-bottom: 1px solid #0cbfdf;
}
#navCircle li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}
#navCircle a:link, #navCircle a:visited {
float: left;
font-size: 14px;
line-height: 10px;
font-weight: bold;
padding: 0 20px 6px 8px;
text-decoration: none;
color: #0cbfdf;
}
#navCircle a:link.active, #navCircle a:visited.active, #navCircle a:hover {
padding-bottom: 13px;
color: #FFFFDD;
background: url(./photos-espace-mariage/image-menu.jpg) no-repeat bottom center;
}
</style>
</head>
<body>
<table width="100%" border="0" id="entete">
<tr>
<td width="63%" height="127"><a href="../index.html"><img src="../photos-espace-mariage/espace-mariage.jpg" width="474" height="127" border="0" /></a></td>
<td width="37%" valign="bottom"><blockquote>
<p align="justify" class="Style10"><a name="haut" id="haut"></a></p>
<p align="justify" class="Style3">Le seul espace mariage en France où les professionnels du mariage répondent à vos questions et vous guident tout au long des préparatifs de votre mariage</p>
<p align="center" class="Style10"><img src="../photos-espace-mariage/bouton-prestataires.png" width="320" height="38" /><br />
</p>
</blockquote></td>
</tr>
</table>
<table width="1074" height="39" align="center">
<tr align="center">
<td>
<ul id="navCircle">
<!-- CSS Tabs -->
<li><a href="../index.html">Accueil</a></li>
<li><a href="../article-mariage/index.html">Conseils</a></li>
<li><a href="http://www.sokebana.net/forum-mariage" target="_blank">Forum</a></li>
<li><a href="../a-la-une/index.html">A la Une</a></li>
<li><a href="../coup-de-coeur/index.html">Coup de coeur</a></li>
<li><a href="prestataires-mariage/index.html">Prestataires</a></li>
<li><a href="../demande-devis.html">Appels d\'offre</a></li>
<li><a href="../salons-du-mariage/index.html">Salons du mariage</a></li>
<li><a href="../boite-a-outil/index.html">Boite à outils</a></li>
</ul>
</td>
</tr>
</table>
<p>
<p>
<p align="center" class="Style17">Votre soumission a été prise en compte, nous vous en remercions.
</body>
</html>
');
}
else{
echo '<title>Votre soumission n\'est pas prise en compte</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-repeat: no-repeat;
background:#321c0b;
color:#FFFFDD;
font-size:12px;
font-family:Verdana;
background-image: url(../photos-espace-mariage/fond-mariage.jpg);
}
a:link { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:hover { color:#ffffdd; text-decoration:none; font-weight:bold; }
a:visited { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:active { color:#0CBFDF; text-decoration:none; font-weight:bold; }
.Style3 {font-size: 12px}
.Style6 {font-size: 16px}
.Style15 {color: #0CBFDF}
.Style17 {font-size: 14px;color: #0CBFDF;}
.Style16 {font-size: 16px;color: #0CBFDF; }
.Style13 {font-size: 16px; color: #0CBFDF; font-weight:bold;}
.Style9 {font-family: "BernhardFashion BT";font-size: 23px;font-weight: bold;color: #0CBFDF;}
.Style11 {font-family: "BernhardFashion BT";font-size: 30px;color: #0cbfdf;font-weight:bold;}
.Style14 {font-family: "BernhardFashion BT";font-size: 30px;}
.container {
width: 500px; /*largeur menu*/
padding: 5px;
margin: 0px 0 0px 0; /* 1ere valeur = marge depuis le top*/
background: #321D0C; /* fond du menu*/
}
div#menu
{
padding:fixed;
margin-top:0px;
}
div#entete
{
padding:fixed;
margin-top:0px;
}
/* circle */
#navCircle {
margin: 0;
padding: 0 0 23px 20px; /* valeur à 20 = espace entre menu et ligne bleue*/
border-bottom: 1px solid #0cbfdf;
}
#navCircle li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}
#navCircle a:link, #navCircle a:visited {
float: left;
font-size: 14px;
line-height: 10px;
font-weight: bold;
padding: 0 20px 6px 8px;
text-decoration: none;
color: #0cbfdf;
}
#navCircle a:link.active, #navCircle a:visited.active, #navCircle a:hover {
padding-bottom: 13px;
color: #FFFFDD;
background: url(./photos-espace-mariage/image-menu.jpg) no-repeat bottom center;
}
</style>
</head>
<body>
<table width="100%" border="0" id="entete">
<tr>
<td width="63%" height="127"><a href="../index.html"><img src="../photos-espace-mariage/espace-mariage.jpg" width="474" height="127" border="0" /></a></td>
<td width="37%" valign="bottom"><blockquote>
<p align="justify" class="Style10"><a name="haut" id="haut"></a></p>
<p align="justify" class="Style3">Le seul espace mariage en France où les professionnels du mariage répondent à vos questions et vous guident tout au long des préparatifs de votre mariage</p>
<p align="center" class="Style10"><img src="../photos-espace-mariage/bouton-prestataires.png" width="320" height="38" /><br />
</p>
</blockquote></td>
</tr>
</table>
<table width="1074" height="39" align="center">
<tr align="center">
<td>
<ul id="navCircle">
<!-- CSS Tabs -->
<li><a href="../index.html">Accueil</a></li>
<li><a href="../article-mariage/index.html">Conseils</a></li>
<li><a href="http://www.sokebana.net/forum-mariage" target="_blank">Forum</a></li>
<li><a href="../a-la-une/index.html">A la Une</a></li>
<li><a href="../coup-de-coeur/index.html">Coup de coeur</a></li>
<li><a href="prestataires-mariage/index.html">Prestataires</a></li>
<li><a href="../demande-devis.html">Appels d\'offre</a></li>
<li><a href="../salons-du-mariage/index.html">Salons du mariage</a></li>
<li><a href="../boite-a-outil/index.html">Boite à outils</a></li>
</ul>
</td>
</tr>
</table>
<p>
<p>
<p align="center" class="Style17">Une erreur est survenue lors de l\'envoi du message.
</body>
</html>';
}
}
else{
//il y a des champs vide
echo '<title>Votre soumission n\'est pas prise en compte</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-repeat: no-repeat;
background:#321c0b;
color:#FFFFDD;
font-size:12px;
font-family:Verdana;
background-image: url(../photos-espace-mariage/fond-mariage.jpg);
}
a:link { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:hover { color:#ffffdd; text-decoration:none; font-weight:bold; }
a:visited { color:#0CBFDF; text-decoration:none; font-weight:bold; }
a:active { color:#0CBFDF; text-decoration:none; font-weight:bold; }
.Style3 {font-size: 12px}
.Style6 {font-size: 16px}
.Style15 {color: #0CBFDF}
.Style17 {font-size: 14px;color: #0CBFDF;}
.Style16 {font-size: 16px;color: #0CBFDF; }
.Style13 {font-size: 16px; color: #0CBFDF; font-weight:bold;}
.Style9 {font-family: "BernhardFashion BT";font-size: 23px;font-weight: bold;color: #0CBFDF;}
.Style11 {font-family: "BernhardFashion BT";font-size: 30px;color: #0cbfdf;font-weight:bold;}
.Style14 {font-family: "BernhardFashion BT";font-size: 30px;}
.container {
width: 500px; /*largeur menu*/
padding: 5px;
margin: 0px 0 0px 0; /* 1ere valeur = marge depuis le top*/
background: #321D0C; /* fond du menu*/
}
div#menu
{
padding:fixed;
margin-top:0px;
}
div#entete
{
padding:fixed;
margin-top:0px;
}
/* circle */
#navCircle {
margin: 0;
padding: 0 0 23px 20px; /* valeur à 20 = espace entre menu et ligne bleue*/
border-bottom: 1px solid #0cbfdf;
}
#navCircle li {
margin: 0;
padding: 0;
display: inline;
list-style-type: none;
}
#navCircle a:link, #navCircle a:visited {
float: left;
font-size: 14px;
line-height: 10px;
font-weight: bold;
padding: 0 20px 6px 8px;
text-decoration: none;
color: #0cbfdf;
}
#navCircle a:link.active, #navCircle a:visited.active, #navCircle a:hover {
padding-bottom: 13px;
color: #FFFFDD;
background: url(./photos-espace-mariage/image-menu.jpg) no-repeat bottom center;
}
</style>
</head>
<body>
<table width="100%" border="0" id="entete">
<tr>
<td width="63%" height="127"><a href="../index.html"><img src="../photos-espace-mariage/espace-mariage.jpg" width="474" height="127" border="0" /></a></td>
<td width="37%" valign="bottom"><blockquote>
<p align="justify" class="Style10"><a name="haut" id="haut"></a></p>
<p align="justify" class="Style3">Le seul espace mariage en France où les professionnels du mariage répondent à vos questions et vous guident tout au long des préparatifs de votre mariage</p>
<p align="center" class="Style10"><img src="../photos-espace-mariage/bouton-prestataires.png" width="320" height="38" /><br />
</p>
</blockquote></td>
</tr>
</table>
<table width="1074" height="39" align="center">
<tr align="center">
<td>
<ul id="navCircle">
<!-- CSS Tabs -->
<li><a href="../index.html">Accueil</a></li>
<li><a href="../article-mariage/index.html">Conseils</a></li>
<li><a href="http://www.sokebana.net/forum-mariage" target="_blank">Forum</a></li>
<li><a href="../a-la-une/index.html">A la Une</a></li>
<li><a href="../coup-de-coeur/index.html">Coup de coeur</a></li>
<li><a href="prestataires-mariage/index.html">Prestataires</a></li>
<li><a href="../demande-devis.html">Appels d\'offre</a></li>
<li><a href="../salons-du-mariage/index.html">Salons du mariage</a></li>
<li><a href="../boite-a-outil/index.html">Boite à outils</a></li>
</ul>
</td>
</tr>
</table>
<p>
<p>
<p align="center" class="Style17">Merci de remplir tous les champs.
</body>
</html>';
}
?>