title: Output HTML form to .txt file
body: <p>So I have tried many solutions, many different ways of writing this including reading online and here. This is something so simple, yet I have no idea what I'm doing wrong!</p>
  
  <p>Here is a snippet of the form:</p>
  
  <pre><code>&lt;form class="form-inline signup signup-form" role="form" action="submit-email.php" method="POST"&gt; 
   &lt;div class="form-group"&gt;
    &lt;input type="email" class="form-control" id="Email1" name="Email1" placeholder="Enter your email address"&gt;
   &lt;/div&gt;
    &lt;button type="submit" class="btn btn-theme" value="Save Email"&gt;Get notified!&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the 'submit-email.php'.</p>
  
  <pre><code>&lt;?php
  /**
   * Trying to write the contents of the HTML form to .txt
   */
   error_reporting(E_ALL); ini_set('display_errors', 1);
  
  // All the values of the HTML form are securely stored in the array $v:
  $v = array_map('trim', filter_input_array(INPUT_POST));
  
  // Text formatting:
  $text = '-- START ' . date('c') . ' --\n'
      . "User email:{$v['email']}\n";
  
  // Following lines of code open, write, and close your connection
  // to a text file:
  $file = 'emails.txt';
  $fp = fopen($file, 'w');
  fwrite($handle, $text);
  fclose($fp);
  </code></pre>
  
  <p>One of the other attempts:</p>
  
  <pre><code>&lt;?php
  $file = 'emails.txt'
  $email = $_POST['Email1'];
  $fp = fopen("emails.txt", "a");
  $savestring = $email . "\n";
  fwrite($fp, $savestring);
  fclose($fp);
  echo "&lt;h1&gt;Thank you, we will be in touch as soon as possible!&lt;/h1&gt;";
  </code></pre>
  
  <blockquote>
    <p>still need to add a javascript popup/alert instead of just echo. But if someone can help with the file output at least - it would be greatly appreciated!</p>
  </blockquote>
  
  <p>Here are the errors - not reading the 'email' variable even if I set it (as if it's not POST-ing properly:</p>
  
  <pre><code>Notice: Undefined index: email in /Applications/XAMPP/xamppfiles/htdocs/apa_dev/submit-email.php on line 12
  
  Warning: fopen(emails.txt): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/apa_dev/submit-email.php on line 17
  
  Notice: Undefined variable: handle in /Applications/XAMPP/xamppfiles/htdocs/apa_dev/submit-email.php on line 18
  
  Warning: fwrite() expects parameter 1 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/apa_dev/submit-email.php on line 18
  
  Warning: fclose() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/apa_dev/submit-email.php on line 19
  </code></pre>
  
  <p>Keeping in mind I have tried many different ways to write this.</p>