title: sweetalert2 save form input
body: <p>i've made this sweetalert but i have a problem, i would like the password entered in the input to be saved (via the php code in the data.php file) to a txt file. The form works (i'm able to insert the password) but the password inserted is not saved to a txt file. </p>
  
  <p>SWAL CODE : </p>
  
  <pre><code>swal({
  title: 'Submit to confirm',
  html:
      '&lt;input id="swal-input1" placeholder="Password" class="form-control mb-1" type="password"&gt;',
  showCancelButton: true,
  confirmButtonText: 'Submit',
  showLoaderOnConfirm: true,
  buttonsStyling: false,
  confirmButtonClass: 'btn btn-primary btn-lg',
  cancelButtonClass: 'btn btn-lg',
  preConfirm: function () {
      return new Promise((resolve, reject) =&gt; {
  
              resolve({
                  Password: $('input[placeholder="Password"]').val()
              });
  
  
          });
  },
  allowOutsideClick: false
  }).then(function (result) {
      $.ajax({
          type:'GET',
          data:Password,
          url:'data.php',
          success:function(data) {
              alert(data);
          }
      });
   }).catch(swal.noop)
  </code></pre>
  
  <p>PHP CODE (that save the input value to a txt file) --> data.php</p>
  
  <pre><code>&lt;?php
  $txt = "data.txt"; 
  if (isset($_GET['swal-input1'])) { 
  $fh = fopen($txt, 'a'); 
  $txt=$_GET['swal-input1']; 
  fwrite($fh,$txt); // Write information to the file
  fclose($fh); // Close the file
  }
  ?&gt; 
  </code></pre>
  
  <p>Thank you, hope you help me.</p>