title: Send Data From FORM JSON; using async fetch await to PHP MySQL
body: <p>Since few days I try to fixed this issue. 
  What it's needed:
  1) post data from JSON (async fetch await) to php
  2) receive the data and upload it on my server</p>
  
  <p>Actually, from now, I receive an answer from my PHP but this one is empty in my console.log.</p>
  
  <p>please see the code below:</p>
  
  <p>Send Data From FORM JSON; using async fetch await to PHP MySQL</p>
  
  <p>Thanks for your help and as usual, I continue to find the answer. This one will be post.</p>
  
  <p><strong>the form</strong>     </p>
  
  <pre><code>  &lt;form id="form"&gt;
      &lt;div id="areachatbox"&gt;&lt;/div&gt;
      &lt;textarea type="text" id="message" name="message" &gt;&lt;/textarea&gt;
      &lt;input id="submit" type="submit" value="Send"&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p><strong>the JSON:</strong></p>
  
  <pre><code>        &lt;script&gt;
  const form = document.getElementById('form');
  
   form.addEventListener('click', textarea);
  
       async function textarea(event) {
        event.preventDefault();
  
        const msg = document.getElementById('message').value;
  
  
  
        const response = await fetch('chatpost.php', {
          method: 'post',
          body:JSON.stringify({msg})
        })
  
        const data = await response.text();
        console.log(data);
      }
  
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>and the PHP</strong></p>
  
  <pre><code>&lt;?php 
  
  $json = json_decode(file_get_contents('http://localhost/XXXXXX/homepage.php'), true);
  
  echo $json['msg'];
  
  ?&gt; 
  </code></pre>