title: Load php function after JS function call
body: <p>In my website I have to read, edit and save some datas. I perform it in this way:</p>
  
  <ol>
  <li>Load with PHP a text file called <code>database.txt</code> (stored in the server) in a textarea that has <code>id="testo"</code></li>
  <li>Call <code>importa();</code> that is a javascript function that edit the text inside <code>testo</code></li>
  <li>I save content of the textarea inside <code>database.txt</code></li>
  </ol>
  
  <p>This is the code I use to load the text inside the textarea:</p>
  
  <pre><code> &lt;?php
  $myFile = "database.txt";
  $fh = fopen($myFile, 'r');
  $theData = fread($fh, filesize($myFile));
  fclose($fh);
  echo '&lt;textarea id="testo" style="width:100%;display:block;"&gt;'.$theData.'&lt;/textarea&gt;';
  ?&gt;
  </code></pre>
  
  <p>I have a button <code>Save</code> that calls <code>importa();</code>.</p>
  
  <pre><code>&lt;input type="button" id="salvauser" value="Save" style="width:100%" onclick="document.getElementById('settings').style.display='none';importa();" /&gt;
  </code></pre>
  
  <p>Now I have the textarea that is edited from importa and I must save its text to <code>database.txt</code>. I wrote this function:</p>
  
  <pre><code>&lt;?php
  $testo = $_POST['testo']."\r\n";
  $documento ="database.txt";
  $identificatore = fopen($documento, "a");
  if (!fwrite($identificatore, $testo)){
  echo"?PHP ERROR: Cannot save the file. Script not loaded.";
  exit;
  }
  else {
  fclose($identificatore);
  header('Location: http://escaperope.altervista.org/testsito/index.php');
  }
  ?&gt;
  </code></pre>
  
  <p>It saves the content of the textarea, but I don't know how to call this PHP script after calling <code>importa();</code> (I am new with PHP). Do you have any suggestions? </p>
  
  <p>Here you can see <code>importa();</code></p>
  
  <pre><code>function addText(elId,text) {
      document.getElementById(elId).value += text;
  }
  
  //addText allows me to add the text inside the textarea
  
  function importa() {
   addText("testo",document.getElementById("nome2").value + ":" + document.getElementById("fc2").value+":" + document.getElementById("poke1").value + ":" + document.getElementById("poke2").value + ":" + document.getElementById("poke3").value + "tipo");
  }
  </code></pre>