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
|
<?php
var_dump($_POST);
//connexion à ma BDD perso
$connect = mysqli_connect("", "", "", "");
//enregistrement 'dateenvoi' dans BDD
if (!empty($_POST)) {
//si post n'est pas vide, on vérifie que toutes les données sont présentes (isset signifie " est ce que ca existe")
if (isset($_POST["dateEnvoi"]) && !empty($_POST["dateEnvoi"])) {
//la donnée est bien indiquée
//on récupère les données en les protégeant (failles XXS)
$envoi = strip_tags($_POST["dateEnvoi"]); // on neutralise toutes les balises html
//on enregistre les données
//On se connecte à la base de données
$servname = "";
$dbname = "";
$user = "";
$pass = "";
try {
$dbco = new PDO("mysql:host=$servname;dbname=$dbname", $user, $pass);
$dbco->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $donnees = "INSERT INTO 'exemple'('dateEnvoi')VALUES (:dateEnvoi)";
//on prépare la requête
$query = $dbco->prepare("INSERT INTO exemple(dateEnvoi)VALUES (:envoi)");
//on injecte les valeurs
$query->bindValue(":envoi", $envoi);
//on exécute la Requete
$query->execute();
} catch (PDOException $e) {
echo "Erreur : " . $e->getMessage();
}
}
}
//affichage des données
$query = "SELECT identifiant,nom,prenom,adresse,complementAdresse,ville,codePostal,mail,fixe,portable,kit,tube,aiguille,adaptateur,cartonSmall,cartonBig,etiquetteChronopost,enveloppeBulle,commentaire,dateCommande,dateEnvoi FROM exemple";
$res = mysqli_query($connect, $query);
if (mysqli_num_rows($res) > 0) {
$export = '
<style>
// table{
// border: #26b72b 1px solid ;
// }
td{
border:black 1px solid;
padding:20px;
}
h1{
text-decoration:underline;
}
</style>
<h1>Tableau de toutes les commandes </h1>
<table>
<tr>
<th>identifiant</th>
<th>nom</th>
<th>prenom</th>
<th>adresse</th>
<th>complement adresse</th>
<th>ville</th>
<th>code postal</th>
<th>mail</th>
<th>fixe</th>
<th>portable</th>
<th>nbre de kits</th>
<th>nbre de tubes</th>
<th>nbre aiguilles</th>
<th>nbre adaptateur</th>
<th>nbre petit carton</th>
<th>nbre grand carton</th>
<th>nbre etiquette chronopost</th>
<th>nbre enveloppe bulle</th>
<th>commentaire</th>
<th>date commande</th>
<th>date d envoi</th>
</tr>
';
while ($row = mysqli_fetch_array($res)) {
$export .= '
<tr>
<td>' . $row["identifiant"] . '</td>
<td>' . $row["nom"] . '</td>
<td>' . $row["prenom"] . '</td>
<td>' . $row["adresse"] . '</td>
<td>' . $row["complementAdresse"] . '</td>
<td>' . $row["ville"] . '</td>
<td>' . $row["codePostal"] . '</td>
<td>' . $row["mail"] . '</td>
<td>' . $row["fixe"] . '</td>
<td>' . $row["portable"] . '</td>
<td>' . $row["kit"] . '</td>
<td>' . $row["tube"] . '</td>
<td>' . $row["aiguille"] . '</td>
<td>' . $row["adaptateur"] . '</td>
<td>' . $row["cartonSmall"] . '</td>
<td>' . $row["cartonBig"] . '</td>
<td>' . $row["etiquetteChronopost"] . '</td>
<td>' . $row["enveloppeBulle"] . '</td>
<td>' . $row["commentaire"] . '</td>
<form method="post" action="">
<td>' . $row["dateCommande"] . '</td>
<td><div align="center"><input type="text" name="dateEnvoi" value="' . $row["dateEnvoi"] . '"/> </td>
<td><button type="submit">Enregistrer</button></td>
</form>
</tr>
';
}
$export .= '</table>';
// header('Content-Type: application/xls');
// header('Content-Disposition: attachment; filename=commande-ifce.xls');
echo $export;
} ?> |
Partager