IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Envoi d'un textarea dans une bdd


Sujet :

Langage PHP

  1. #1
    Membre du Club Avatar de IamKanagawa
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2018
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2018
    Messages : 114
    Points : 54
    Points
    54
    Par défaut Envoi d'un textarea dans une bdd
    Bonsoir à tous,

    Voila je n'arrive pas à envoyer mon champs TEXTAREA dans ma BDD, je saisis mon champs nom et mon champs appreciation(TEXTAREA) mais il n'y a que le nom qui s'envoie je n'arrive pas a trouver mon erreur pouvez vous m'aider SVP.

    PS:Mon champs appreciation(TEXTAREA) est en saisir vocale avec une APi donc je ne sais pas si ça modifie quelque chose mais je prefere le dire

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <!DOCTYPE html>
        <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <title>Saisir appreciation</title>
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="stylesheet" href="style.css">
     
    </head>
    <body>
     
        <h3><u>Saisir Appréciation</u></h3>
     
        <div class="form_style_1">
            <form action="traitement.php" method="POST">
                <!-- Zone de saisi pour le champs NOM -->
                <label> Saisir le nom de l'eleve :</label> <input type="text" class="form-control" name="nom" placeholder="Nom" >
                <br />
                <!-- Zone de saisi pour le champs nom -->
                <label> Saisir appréciation :</label> <textarea id="note-textarea" name="appreciation" placeholder=" appréciation ..." rows="6"></textarea>
                <button id="save-note-btn" title="Save Note">Valider</button>   
                <input type="reset" value="Reset" >
                </form>	
                <!-- Buton enregistrement -->
    			<button id="start-record-btn" title="Start Recording">Reconnaissance Vocale</button>
                <button id="pause-record-btn" title="Pause Recording">Stop Reconnaissance Vocale</button>
     
        </div>
     
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
     
    		<!-- Web Speech API -->
    		<script src="script.js"></script>
     
     
        </body>
    </html>
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <?php
    include "includes/connecte_bdd.php";
    try {
        $appreciation = $_POST['appreciation'];
        $nom = $_POST['nom'];
     
    	$requete = $bdd->prepare("INSERT INTO appreciation(nomAppreciation, appreciation) VALUES(?, ?)");
    	$requete -> bindParam(1, $nom);
    	$requete -> bindParam(2, $appreciation);
     
    	$appreciation = $_POST['appreciation'];
        $nom = $_POST['nom'];
    	//on exécute la requête préparée au préalable
    	$requete -> execute();
     
        $nb_insert = $requete->rowCount();
           echo $nb_insert.' insertion effectuée<br/>';
           echo " <b>$appreciation_appreciation</b> à été ajouté";
           unset($bdd);
        } 
        catch (Exception $e) {
           //s'il y a un problème PHP ou SQL, tout s'affichera ici
           print "Erreur ! " . $e->getMessage() . "<br/>";
        }
    ?>
    Images attachées Images attachées  

  2. #2
    Membre éclairé
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Avril 2017
    Messages
    508
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2017
    Messages : 508
    Points : 770
    Points
    770
    Par défaut
    Bonsoir, essaie de vider les caches et les cookies de ton navigateur.

    Cordialement.

  3. #3
    Membre du Club Avatar de IamKanagawa
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2018
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2018
    Messages : 114
    Points : 54
    Points
    54
    Par défaut
    Malheureusement je l'ai deja fait

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonjour,

    1- Change le TYPE VARCHAR(100) en TEXT (ou LONGTEXT)

    2-
    Citation Envoyé par IamKanagawa Voir le message
    ...PS:Mon champs appreciation(TEXTAREA) est en saisir vocale avec une APi ...
    Vérifier au moins que tu récupères quelque chose !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    	$appreciation = $_POST['appreciation'];
    	echo '<pre>'.$appreciation.'</pre>';

  5. #5
    Membre du Club Avatar de IamKanagawa
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2018
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2018
    Messages : 114
    Points : 54
    Points
    54
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    try {
        var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
        var recognition = new SpeechRecognition();
      }
      catch(e) {
        console.error(e);
        $('.no-browser-support').show();
        $('.app').hide();
      }
     
     
      var noteTextarea = $('#appreciation');
      var instructions = $('#recording-instructions');
      var notesList = $('ul#notes');
     
      var noteContent = '';
     
      var notes = getAllNotes();
      renderNotes(notes);
     
      /*-----------------------------
            Voice Recognition 
      ------------------------------*/
     
      // If false, the recording will stop after a few seconds of silence.
      // When true, the silence period is longer (about 15 seconds),
      // allowing us to keep recording even when the user pauses. 
      recognition.continuous = true;
     
      // This block is called every time the Speech APi captures a line. 
      recognition.onresult = function(event) {
     
        // event is a SpeechRecognitionEvent object.
        // It holds all the lines we have captured so far. 
        // We only need the current one.
        var current = event.resultIndex;
     
        // Get a transcript of what was said.
        var transcript = event.results[current][0].transcript;
     
        // Add the current transcript to the contents of our Note.
        // There is a weird bug on mobile, where everything is repeated twice.
        // There is no official solution so far so we have to handle an edge case.
        var mobileRepeatBug = (current == 1 && transcript == event.results[0][0].transcript);
     
        if(!mobileRepeatBug) {
          noteContent += transcript;
          noteTextarea.val(noteContent);
        }
      };
     
      recognition.onstart = function() { 
        instructions.text('Voice recognition activated. Try speaking into the microphone.');
      }
     
      recognition.onspeechend = function() {
        instructions.text('You were quiet for a while so voice recognition turned itself off.');
      }
     
      recognition.onerror = function(event) {
        if(event.error == 'no-speech') {
          instructions.text('No speech was detected. Try again.');  
        };
      }
     
     
      /*-----------------------------
            App buttons and input 
      ------------------------------*/
     
      $('#start-record-btn').on('click', function(e) {
        if (noteContent.length) {
          noteContent += ' ';
        }
        recognition.start();
      });
     
     
      $('#pause-record-btn').on('click', function(e) {
        recognition.stop();
        instructions.text('Voice recognition paused.');
      });
     
      // Sync the text inside the text area with the noteContent variable.
      noteTextarea.on('input', function() {
        noteContent = $(this).val();
      })
     
      $('#save-note-btn').on('click', function(e) {
        recognition.stop();
     
        if(!noteContent.length) {
          instructions.text('Could not save empty note. Please add a message to your note.');
        }
        else {
          // Save note to localStorage.
          // The key is the dateTime with seconds, the value is the content of the note.
          saveNote(new Date().toLocaleString(), noteContent);
     
          // Reset variables and update UI.
          noteContent = '';
          renderNotes(getAllNotes());
          noteTextarea.val('');
          instructions.text('Note saved successfully.');
        }
     
      })
     
     
      notesList.on('click', function(e) {
        e.preventDefault();
        var target = $(e.target);
     
        // Listen to the selected note.
        if(target.hasClass('listen-note')) {
          var content = target.closest('.note').find('.content').text();
          readOutLoud(content);
        }
     
        // Delete note.
        if(target.hasClass('delete-note')) {
          var dateTime = target.siblings('.date').text();  
          deleteNote(dateTime);
          target.closest('.note').remove();
        }
      });
     
     
     
      /*-----------------------------
            Speech Synthesis 
      ------------------------------*/
     
      function readOutLoud(message) {
          var speech = new SpeechSynthesisUtterance();
     
        // Set the text and voice attributes.
          speech.text = message;
          speech.volume = 1;
          speech.rate = 1;
          speech.pitch = 1;
     
          window.speechSynthesis.speak(speech);
      }
     
     
     
      /*-----------------------------
            Helper Functions 
      ------------------------------*/
     
      function renderNotes(notes) {
        var html = '';
        if(notes.length) {
          notes.forEach(function(note) {
            html+= `<li class="note">
              <p class="header">
                <span class="date">${note.date}</span>
                <a href="#" class="listen-note" title="Listen to Note">Listen to Note</a>
                <a href="#" class="delete-note" title="Delete">Delete</a>
              </p>
              <p class="content">${note.content}</p>
            </li>`;    
          });
        }
        else {
          html = '<li><p class="content">You don\'t have any notes yet.</p></li>';
        }
        notesList.html(html);
      }
     
     
      function saveNote(dateTime, content) {
        localStorage.setItem('note-' + dateTime, content);
      }
     
     
      function getAllNotes() {
        var notes = [];
        var key;
        for (var i = 0; i < localStorage.length; i++) {
          key = localStorage.key(i);
     
          if(key.substring(0,5) == 'note-') {
            notes.push({
              date: key.replace('note-',''),
              content: localStorage.getItem(localStorage.key(i))
            });
          } 
        }
        return notes;
      }
     
     
      function deleteNote(dateTime) {
        localStorage.removeItem('note-' + dateTime); 
      }
    voici le javascripts

    Enfaite quand je retire le id="appreciation" le textarea marche mais l'insertion vocale pour le textarea ne marche plus car je pense qu'il le reconnait plus dans le JS. Par contre quand je retire le name="appreciation" cette fois ci c'est l'insertion vocale qui marche mais pas l'envoie

  6. #6
    Invité
    Invité(e)
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <textarea id="note-textarea" name="appreciation" ...></textarea>
    Relis ton code...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      var noteTextarea = $('#appreciation');
    Il n'y a pas de id="appreciation" .

  7. #7
    Membre du Club Avatar de IamKanagawa
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2018
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2018
    Messages : 114
    Points : 54
    Points
    54
    Par défaut
    Oui je l'ai deja changer ça

    Donc je ne sais pas d'où ça pourrait venir

Discussions similaires

  1. [PHP 5.0] formulaire oui non pour envoie dans une bdd
    Par micker dans le forum Langage
    Réponses: 5
    Dernier message: 10/03/2011, 15h56
  2. Envoi de formulaire dans une BDD
    Par soultaken dans le forum Langage
    Réponses: 2
    Dernier message: 02/06/2010, 20h52
  3. Réponses: 9
    Dernier message: 10/02/2010, 18h30
  4. [MySQL] envoi d'un formulaire dans une BDD
    Par angelusflm dans le forum PHP & Base de données
    Réponses: 8
    Dernier message: 17/02/2009, 10h45
  5. [MySQL] envoi d'image dans une bdd
    Par IRISnse dans le forum PHP & Base de données
    Réponses: 5
    Dernier message: 29/04/2008, 11h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo