UPDATE Base de données !

Julian

Julian Le 6 février 2017 à 18:18 (Édité le 25 janvier 2019 à 17:53)

Bonjour,

Je souhaiterai faire un UPDATE dans ma base de données,

J'ai un formulaire, avec 39 champs text, et un submit.

Dans l'UPDATE je voudrais que cela soit stocké dans ma base de données, mais que si on remplit seulement 1 champ, il soit rentré et que les autres ne change pas de valeur. Je n'arrive pas à faire rentrer seulement un champ, cela ne se rentre pas !

Pouvez-vous m'aider ? Merci.

Mon code au passage :

<?php
include '../bdd.php';
include '../JBBCode/Parser.php';
if (isset($_POST['submit'])) {
   if(isset($_POST['pv1']) || isset( $_POST['pv2']) || isset( $_POST['pv3']) || isset( $_POST['pv4']) || isset( $_POST['pv5']) || isset( $_POST['pv6']) || isset( $_POST['pv7']) || isset( $_POST['pv8']) || isset( $_POST['pv9']) || isset( $_POST['pv10']) || isset( $_POST['pv11']) || isset( $_POST['pv12']) || isset( $_POST['pv13']) || isset( $_POST['id_page']) || isset($_POST['dz1']) || isset( $_POST['dz2']) || isset( $_POST['dz3']) || isset( $_POST['dz4']) || isset( $_POST['dz5']) || isset( $_POST['dz6']) || isset( $_POST['dz7']) || isset( $_POST['dz8']) || isset( $_POST['dz9']) || isset( $_POST['dz10']) || isset( $_POST['dz11']) || isset( $_POST['dz12']) || isset( $_POST['dz13']) || isset($_POST['ds1']) || isset( $_POST['ds2']) || isset( $_POST['ds3']) || isset( $_POST['ds4']) || isset( $_POST['ds5']) || isset( $_POST['ds6']) || isset( $_POST['ds7']) || isset( $_POST['ds8']) || isset( $_POST['ds9']) || isset( $_POST['ds10']) || isset( $_POST['ds11']) || isset( $_POST['ds12']) || isset( $_POST['ds13'])) {
      $id_page = $_POST['id_page'];
      $pv1 = $_POST['pv1'];
      $pv2 = $_POST['pv2'];
      $pv3 = $_POST['pv3'];
      $pv4 = $_POST['pv4'];
      $pv5 = $_POST['pv5'];
      $pv6 = $_POST['pv6'];
      $pv7 = $_POST['pv7'];
      $pv8 = $_POST['pv8'];
      $pv9 = $_POST['pv9'];
      $pv10 = $_POST['pv10'];
      $pv11 = $_POST['pv11'];
      $pv12 = $_POST['pv12'];
      $pv13 = $_POST['pv13'];
      $dz1 = $_POST['dz1'];
      $dz2 = $_POST['dz2'];
      $dz3 = $_POST['dz3'];
      $dz4 = $_POST['dz4'];
      $dz5 = $_POST['dz5'];
      $dz6 = $_POST['dz6'];
      $dz7 = $_POST['dz7'];
      $dz8 = $_POST['dz8'];
      $dz9 = $_POST['dz9'];
      $dz10 = $_POST['dz10'];
      $dz11 = $_POST['dz11'];
      $dz12 = $_POST['dz12'];
      $dz13 = $_POST['dz13'];
      $ds1 = $_POST['ds1'];
      $ds2 = $_POST['ds2'];
      $ds3 = $_POST['ds3'];
      $ds4 = $_POST['ds4'];
      $ds5 = $_POST['ds5'];
      $ds6 = $_POST['ds6'];
      $ds7 = $_POST['ds7'];
      $ds8 = $_POST['ds8'];
      $ds9 = $_POST['ds9'];
      $ds10 = $_POST['ds10'];
      $ds11 = $_POST['ds11'];
      $ds12 = $_POST['ds12'];
      $ds13 = $_POST['ds13'];
      $ins = $bdd->prepare('UPDATE pages SET pv1 = ?, pv2 = ?, pv3 = ?, pv4 = ?, pv5 = ?, pv6 = ?, pv7 = ?, pv8 = ?, pv9 = ?, pv10 = ?, pv11 = ?, pv12 = ?, pv13= ?, dz1 = ?, dz2 = ?, dz3 = ?, dz4 = ?, dz5 = ?, dz6 = ?, dz7 = ?, dz8 = ?, dz9 = ?, dz10 = ?, dz11 = ?, dz12 = ?, dz13 = ?, ds1 = ?, ds2 = ?, ds3 = ?, ds4 = ?, ds5 = ?, ds6 = ?, ds7 = ?, ds8 = ?, ds9 = ?, ds10 = ?, ds11 = ?, ds12 = ?, ds13 = ? WHERE id = '.$id_page.'');
      $ins->execute(array($pv1, $pv2, $pv3, $pv4, $pv5, $pv6, $pv7, $pv8, $pv9, $pv10, $pv11, $pv12, $pv13, $dz1, $dz2, $dz3, $dz4, $dz5, $dz6, $dz7, $dz8, $dz9, $dz10, $dz11, $dz12, $dz13, $ds1, $ds2, $ds3, $ds4, $ds5, $ds6, $ds7, $ds8, $ds9, $ds10, $ds11, $ds12, $ds13));
      $erreur = "Votre article a bien été posté";
    } else {
       $erreur = 'Veuillez remplir tous les champs';
   }
}
?>
<!DOCTYPE html>
<html>
<head>
   <title>Rédaction</title>
   <meta charset="utf-8">
   <link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body style="text-align: center;margin-top: 20%;">
   <form method="POST" enctype="multipart/form-data">
   <h6>PV : POINTS DE VIE | DZ : DEGATS DE ZONE | DS : DEGATS PAR SECONDE</h6><br><br>
   <input type="text" name="id_page" placeholder="ID DE LA PAGE"><br><br>
   <input type="text" name="pv1" placeholder="pv1"><br>
   <input type="text" name="pv2" placeholder="pv2"><br>
   <input type="text" name="pv3" placeholder="pv3"><br>
   <input type="text" name="pv4" placeholder="pv4"><br>
   <input type="text" name="pv5" placeholder="pv5"><br>
   <input type="text" name="pv6" placeholder="pv6"><br>
   <input type="text" name="pv7" placeholder="pv7"><br>
   <input type="text" name="pv8" placeholder="pv8"><br>
   <input type="text" name="pv9" placeholder="pv9"><br>
   <input type="text" name="pv10" placeholder="pv10"><br>
   <input type="text" name="pv11" placeholder="pv11"><br>
   <input type="text" name="pv12" placeholder="pv12"><br>
   <input type="text" name="pv13" placeholder="pv13"><br><br>
   <input type="text" name="dz1" placeholder="dz1"><br>
   <input type="text" name="dz2" placeholder="dz2"><br>
   <input type="text" name="dz3" placeholder="dz3"><br>
   <input type="text" name="dz4" placeholder="dz4"><br>
   <input type="text" name="dz5" placeholder="dz5"><br>
   <input type="text" name="dz6" placeholder="dz6"><br>
   <input type="text" name="dz7" placeholder="dz7"><br>
   <input type="text" name="dz8" placeholder="dz8"><br>
   <input type="text" name="dz9" placeholder="dz9"><br>
   <input type="text" name="dz10" placeholder="dz10"><br>
   <input type="text" name="dz11" placeholder="dz11"><br>
   <input type="text" name="dz12" placeholder="dz12"><br>
   <input type="text" name="dz13" placeholder="dz13"><br><br>
   <input type="text" name="ds1" placeholder="ds1"><br>
   <input type="text" name="ds2" placeholder="ds2"><br>
   <input type="text" name="ds3" placeholder="ds3"><br>
   <input type="text" name="ds4" placeholder="ds4"><br>
   <input type="text" name="ds5" placeholder="ds5"><br>
   <input type="text" name="ds6" placeholder="ds6"><br>
   <input type="text" name="ds7" placeholder="ds7"><br>
   <input type="text" name="ds8" placeholder="ds8"><br>
   <input type="text" name="ds9" placeholder="ds9"><br>
   <input type="text" name="ds10" placeholder="ds10"><br>
   <input type="text" name="ds11" placeholder="ds11"><br>
   <input type="text" name="ds12" placeholder="ds12"><br>
   <input type="text" name="ds13" placeholder="ds13"><br><br>
      
      <input type="submit" name="submit" value="Envoyer l'article">   
   </form>   <br> <?php if(isset($erreur)){echo $erreur; } ?>
</body>
</html>
Balatharas

Balatharas Le 6 février 2017 à 18:28

Tu veux donner la possibilité de remplir un champ mais tu met ça ?
 } else {       $erreur = 'Veuillez remplir tous les champs';   }
Julian

Julian Le 6 février 2017 à 18:34

Oui je sais, c'était un petit test, mais que faire ?
Balatharas

Balatharas Le 6 février 2017 à 20:18

Bah tu enlève le else ? xD
Julian

Julian Le 6 février 2017 à 20:28

Ca ne marche pas..
Vous devez être connecté pour poster une réponse. Se connecter ou Créer un compte