E-mail

Résolu/Fermé
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019 - 28 janv. 2019 à 16:36
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019 - 30 janv. 2019 à 15:23
Salut a tous je voudrais de l'aide s'il vous plaît
J'ai crée un tableau en html avec des cases à cocher ainsi qu'une zone de commentaire

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body style="background-color:#FFFFFF;">

<FORM name="form1" method="POST" action="recup.php?<?PHP echo SID; ?>"
<p></p>
<p style="text-align: center;"><strong>VERIFICATION MATERIEL LIGNE DE CAISSES</strong></p>
<p style="text-align: center;"></p>
<table style="width: 100%; height: 18px; margin-right: auto; margin-left: auto; border-collapse: collapse;" border="1">
<tbody>
<tr style="height: 17px;">
<td style="width: 7%; height: 8px; text-align: center;" rowspan="2">Caisse<strong><span style="text-align: left; color: #000000; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 10px; font-style: normal; font-variant: normal; text-decoration: none; word-spacing: 0px; display: inline !important; white-space: normal; cursor: text; orphans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transparent;"><br /></span></strong></td>
<td style="width: 25%; height: 21px; text-align: center;" colspan="7"><strong><span style="text-align: left; color: #000000; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; text-decoration: none; word-spacing: 0px; display: inline !important; white-space: normal; cursor: text; orphans: 2; float: none; -webkit-text-stroke-width: 0px; background-color: transparent;">Service Technique</span></strong></td>
<td style="width: 25%; height: 21px; text-align: center;" colspan="4"><b>Service Informatique</b></td>
<td style="width: 25%; height: 21px; text-align: center;"><b>commentaire<br /></b></td>
</tr>
<tr style="height: 17px;">
<td style="width: 3.09%; height: 17px; text-align: center;">Tapis</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Embout</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Luminaire</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Ecran</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Battant</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Mirroir</td>
<td style="width: 6.19%; height: 17px; text-align: center;">Tel </td>
<td style="width: 7.83%; height: 17px; text-align: center;">TPE</td>
<td style="width: 7.83%; height: 17px; text-align: center;">Imprimante</td>
<td style="width: 7.83%; height: 17px; text-align: center;">Scanner</td>
<td style="width: 7.83%; height: 17px; text-align: center;">Caisse(ordi)</td>
<td style="width: 43.33%; height: 17px;" 17px="" 5=""><form><textarea name="nom" rows="3" cols="53"></textarea></form></td>
</tr>
<tr>
<td style="width: 7%; text-align: center;">1</td>
<td style="width: 3.09%; text-align: center;"><form>
<div>
<div>
<input name="a_1" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div style="text-align: center;">
<input name="a_2" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div><input name="a_3" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div><input name="a_4" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div><input name="a_5" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div><input name="a_6" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 6.19%; text-align: center;"><form>
<div>
<div><input name="a_7" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 7.83%; text-align: center;"><form>
<div>
<div><input name="a_8" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 7.83%; text-align: center;"><form>
<div>
<div><input name="a_9" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 7.83%; text-align: center;"><form>
<div>
<div><input name="a_10" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 7.83%; text-align: center;"><form>
<div>
<div><input name="a_11" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>
</div>
</form></td>
<td style="width: 43.33%;"><form><textarea name="nom" rows="3" cols="53"></textarea></form></td>
</tr>
</tbody>
</table>
<p></p>
<p></p>
 <a href="jordi.desroses@gmail.com" target="_blank"> <input type="button" value="Verification" accesskey="s">
</body>
</html> 

Je voudrais savoir si il est possible que lorsque l'utilisateur coche et écrit son commentaire celui-ci est envoyer par mail "seulement les élément coché et le commentaire"
A voir également:

2 réponses

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
28 janv. 2019 à 23:55
Bonjour,

La réponse à ta question est Oui.

Commence par regarder ce que contiennent ta variable $_POST
ainsi tu verras comment récupérer les variables et ainsi les mettre dans ton mail.

Je t'invite à lire ceci (surtout la partie récupération "propre" des variables )
https://forums.commentcamarche.net/forum/affich-37584947-php-gestion-des-erreurs-debogage-et-ecriture-du-code

Pour ce qui est de l'envoie de mail...
Si tu bosses en LOCAL sur ton ordi ( via un logiciel comme wamp, xampp, easyphp, Uwamp ...etc....)
la fonction "mail" ne fonctionnera pas.
Du mois.. pas sans configurer le smtp et éventuellement installer un logiciel comme fakesendmail (tu trouveras sur le net le tutos pour l'utiliser).
Sinon tu as la possibilité d'utiliser une class php comme phpmailer (et alors utiliser ton adresse mail gmail, live ou autre..selon ton choix...)

NB: Tu as des balises <form></form> en trop dans ton code....
Tu dois placer tous les champs que tu désires récupérer entre un seul "couple" de form
<form name="form1" method="post" action="recup.php?<?php echo SID; ?>"
  <!-- ICI TU PLACES TOUS LES CHAMPS A RECUPERER LORS DU SUBMIT -->




  <input type="submit" value="envoyer"> <!-- Bouton pour envoyer le formulaire-->
</form>


Autre point...
Si tu veux utiliser des checkbox pour une même chose... il faut utiliser le nommage sous forme d'array
au lieu de name="a_6" name="a_7" ...
<input name="a[]" id="scales" type="checkbox" checked="checked" /> <label for="OFF">HS</label></div>



Puis...
<label for="OFF"

le "for" fait référence à l' ID d'un élément html ... hors.. ton "OFF" ne correspond à rien !
Ici ça serait
<label for="scales"


Et pour finir ... un ID se doit d'être UNIQUE
Donc.. mettre id="scales" à tous tes champs n'est pas valide !




1
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
29 janv. 2019 à 13:29
Bonjour
Super ! Merci a toi pour ton aide et grâce au tôt je pourrais avancer j'en te remercie
et encore une choses quand je crée mon fichier php.ini il y aura seulement les variables que je récupere qui seront envoyer par mail ?
0
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650 > Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
29 janv. 2019 à 13:34
Oui...Relis ma réponse...
0
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
Modifié le 29 janv. 2019 à 15:15
D'accord je te remercie
Sachant que je travaille dans le cadre de l'entreprise C*****r" Disposant d'un serveur "
Je n'aurais pas besoin de la class phpMailer ?


EDIT : Suppression du nom de l'entreprise.
0
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650 > Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
29 janv. 2019 à 15:14
Je pense que leur serveur dispose de la fonction mail.
https://www.php.net/manual/fr/function.mail.php
0
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
Modifié le 29 janv. 2019 à 15:31
D'accord encore merci beaucoup pour ton aide je vais essayer de suite :)

Donc petit récap " On récupere les données , on vérifie si elles existent , puis on les envoie c'est sa ?"
0
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
30 janv. 2019 à 15:11
<?php


//Afficher les erreurs

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

// Le tableau $_POST['a'] contient les valeurs des checkbox cochées
$monArray = !empty($_POST['a']) ? $_POST['a'] : NULL;

if(!empty($monArray)){ // si mon array n'est pas vide
  foreach($monArray as $valeur){
     echo " <br> La checkbox $valeur a été cochée<br>";
    
	}
}else
{ // si monArray est vide (tu pourras retirer ce bloc une fois que ton code fonctionnera.. )
  echo "<br>Aucune valeur disponible !";
  echo "<pre>";
  print_r($_POST); // le temps des tests
  echo "</pre>";
}

   
//Si la variable $_POST['nom'] existe et n'est pas vide, j'en récupère la valeur, sinon je mets la variable $nom à NULL
$nom = !empty($_POST['nom']) ? $_POST['nom'] : NULL

//Destinataires
 $to = exemple@domaine.com ' ;

// Sujet
$subject = " Test d'envoie des données ";

//message

$message = ' Le ficher Html'


<html>
<head>	
<title></title>
</head>
<body>
</body>
</html>
;


// validation
$Verification=true;
if (!$Verification) {
  echo "Error";
  exit;

 // Pour envoyer un mail HTML, l'en-tête Content-type doit être défini
     $headers[] = 'MIME-Version: 1.0';
     $headers[] = 'Content-type: text/html; charset=iso-8859-1';

     // Envoi
     mail($to, $subject, $message, implode("\r\n", $headers));
?> 



Je me suis relus plusieurs fois normalement il ne doit pas y avoir d'erreur
0
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
Modifié le 30 janv. 2019 à 15:16
Perdu. :-)
Encore une quote oubliée...
$to = exemple@domaine.com ' ;


et le pavé HTML tout seul au milieu
$message = ' Le ficher Html'


<html>
<head> 
<title></title>
</head>
<body>
</body>
</html>
;

... ça générera également des erreurs

Pour l'instant, remplace par :

$message = "
         <html>
          <body>
             <h1> Le ficher Html</h1>
             <div style='color:green'>
              (c'est ici que tu mettras le message à envoyer...)
             </div>
           </body>
         </html> ";

</code>
0
Jordi.D Messages postés 51 Date d'inscription vendredi 11 janvier 2019 Statut Membre Dernière intervention 8 février 2019
30 janv. 2019 à 15:23
D'accord merci de m'accorder du temps pour résoudre mon problème
Merci infiniment
0