formulaire avec pièces jointes
Bonjour,
Je dois modifié un formulaire existant , je dois ajouté un champ "pièces jointes" et l expéditeur dois pouvoir également recevoir une copie du mail
Je suis tjs à la recherche de code concernant l'ajout de pièce jointe dans un formulaire.
J'utilise la fonction mail() sauf que je vois pas comment récupérer les pièces jointes
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 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
<?php
if(!empty($_POST))
{
echo '<pre>'; print_r($_POST); echo '</pre>';
$boundary = md5(rand()); // clé aléatoire de limite
// entête email
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: multipart/mixed;boundary='.$boundary.'; charset=UTF-8'."\n";
$headers .= 'Reply-To: Fra
@laboratoire-labeo.fr'."\n";
$headers .= 'From: "' . ucfirst(substr($_POST['email'], 0, strpos($_POST['email'], '@'))) . '"<'.$_POST['email'].'>' . "\n";
$headers .= 'Delivered-to: FrEVIN@laboratoire-labeo.fr' . "\n";
$message ="Objet : FILIATION Commande KIT "."<br><br>". "Nom : " . $_POST['nom'] ."<br>". "Prénom : " . $_POST['prenom'] ."<br>"."Numéro d'identification : " . $_POST['identitficateur']."<br><br>"."Rue : " . $_POST['street'] ."<br>"."Code postal : " . $_POST['postal'] ."<br>"."Ville : " . $_POST['city'] ."<br>"."Email : " . $_POST['email'] ."<br>"."Téléphone portable : " . $_POST['phone'] ."<br>"."Téléphone fixe: " . $_POST['tel']."<br><br>"."Nombre de kits : "."<strong>". $_POST['number-kits']."</strong>"."<br><em>(1 Kit contient 1 sachet étanche, 1 rack compartimenté, 1 planche de 5 étiquettes)</em><br>"."<br>". "Nombres de tubes et aiguilles : "."<strong>". $_POST['number-aiguilles'] ."</strong>"."<br><em>(1 tube = aiguille)</em><br>"."<br>". "Nombres d'adaptateur : "."<strong>" . $_POST['number-adaptateur']."</strong>" ."<br><br>". "Petit carton + étiquette Chronopost Retour : "."<strong>" . $_POST['number-small'] ."</strong>"."<br><br>". "Grand carton + étiquette Chronopost retour : "."<strong>" . $_POST['number-big']."</strong>" ."<br><br>"."Commentaire : "."<br><strong>". $_POST['message']."</strong><br>" ;
mail("GaX@labeo.fr", "Objet : FILIATION Commande KIT ", $message, $headers);
header("location:form-merci.php");
}
?>
<body>
<div class="contact container">
<div class="row mt-4 ">
<div class="col-12 text-center bg-light ">
<h1>Commande de kits génomique</h1>
<form method="post" action="" enctype="multipart/form-data">
<div class="form-row justify-content-center bg-light py-5">
<div class="form-group col-lg-3">
<label for="identity-number">Identificateur</label>
<input type="text" class="form-control" id="identitficateur" name="identitficateur" required/>
<div class="invalid-feedback">
Numéro inconnu
</div>
<div class="valid-feedback">
Numéro reconnu
</div>
</div>
<div class="form-group col-lg-5">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required/>
</div>
<div class="form-group col-lg-5">
<label for="nom">Nom</label>
<input type="text" disabled="disabled" class="form-control" id="nom" name="nom" required>
</div>
<div class="form-group col-lg-5">
<label for="prenom">Prénom</label>
<input type="text" disabled="disabled" class="form-control" id="prenom" name="prenom" required>
</div>
<div class="form-group col-lg-10">
<label for="street">Rue</label>
<input type="text" disabled="disabled" class="form-control" id="street" name="street" required/>
</div>
<div class="form-group col-lg-5">
<label for="postal">Code Postal</label>
<input type="text"disabled="disabled" class="form-control" id="postal" name="postal"maxlength="5" pattern="[0-9]{5}" title="5 chiffres" required/>
</div>
<div class="form-group col-lg-5">
<label for="city">Ville</label>
<input type="text"disabled="disabled" class="form-control" id="city" name="city" required/>
</div>
<div class="form-group col-lg-5">
<label for="phone">Teléphone Portable</label>
<input type="text" disabled="disabled" class="form-control" id="phone" name="phone" pattern="[0-9]{10}" required/>
</div>
<div class="form-group col-lg-5">
<label for="tel">Téléphone Fixe</label>
<input type="text" disabled="disabled" class="form-control" id="tel" name="tel" pattern="[0-9]{10}" />
</div>
<div class="form-group col-lg-3">
<label for="kit">Kits </label><br>
<!-- <input type="number" disabled="disabled" class="form-control" id="kit" name="kit" required/> -->
<select name="number-kits" id="number-kits" disabled="disabled" required>
<option value=""></option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="150">150</option>
<option value="200">200</option>
</select>
</div>
<div class="form-group col-lg-2">
<label for="aiguilles">Tubes et Aiguilles</label><br>
<!-- <input type="number" disabled="disabled" class="form-control" id="aiguilles" name="aiguilles" required/> -->
<select name="number-aiguilles" id="number-aiguilles" disabled="disabled">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="150">150</option>
<option value="200">200</option>
</select>
</div>
<div class="form-group col-lg-2">
<label for="adaptateur">Adaptateur</label><br>
<!-- <input type="number"disabled="disabled" class="form-control" id="adaptateur" name="adaptateur" required/> -->
<select name="number-adaptateur" id="number-adaptateur" disabled="disabled">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<div class="form-group col-lg-2">
<label for="small-box">Petit carton + étiquette retour</label><br>
<!-- <input type="number" disabled="disabled" class="form-control" id="small-box" name="small-box" required/> -->
<select name="number-small" id="number-small" disabled="disabled">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group col-lg-3">
<label for="big-box">Grand carton + étiquette retour</label><br>
<!-- <input type="number" disabled="disabled" class="form-control" id="big-box" name="big-box"required/> -->
<select name="number-big" id="number-big" disabled="disabled">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group col-lg-10">
<label>Vos commentaires</label>
<textarea class="form-control" disabled="disabled" id="message" rows="3" name="message" ></textarea>
</div>
<div class="form-group col-lg-10">
<label> Pièce jointe </label>
<input type="file" name="fichier" id="fichier" multiple>
</div>
<div class="form-group col-lg-10 "style="display:flex">
<div class="form-group col-lg-1 ">
<input type="checkbox" class="form-control" id="rgpd" name="rgpd" required/>
</div>
<div class="form-group col-lg-8 ">
<label for="rgpd"class="rgpd"> En cochant cette case, jaccepte <a href="https://www.laboratoire-labeo.fr/fr/politique-de-confidentialite/">la Politique de confidentialité </a>de ce site </label>
</div>
</div>
<input type="submit" disabled="disabled" name="valider" id="valider" value="Valider" class="form-control btn btn-light text-dark"/>
</div>
</form>
</div>
</body> |