title: My email is sending again when I refresh my page
body: <p>I found this code online, and it works like a charm only for one thing... I was also trying to add a phone number but I keep getting an error every time... I would imagine that I would just add it to the body but every time i try to, it fails. im not really sure what im doing wrong. Im fairly new to PHP so if someone could explain to me why this is happening, that would be greatly appreciated. The content is stored into a folder, but it doesnt seem that folder is refreshed once the email is sent... :\ </p>
  
  <pre><code> &lt;?php
  $msg = "";
  
  if (isset($_POST['submit'])) {
  
      require 'phpmailer/PHPMailerAutoload.php';
  
      function sendemail($to, $from, $fromName, $body, $attachment = "") {
          $mail = new PHPMailer();
          $mail-&gt;setFrom($from, $fromName);
          $mail-&gt;addAddress($to);
          $mail-&gt;addAttachment($attachment);
          $mail-&gt;Subject = 'Contact Form - Email';
          $mail-&gt;Body = $body;
          $mail-&gt;isHTML(false);
  
          return $mail-&gt;send();
      }
  
      $name = $_POST['username'];
      $email = $_POST['email'];
      $body = $_POST['body'];
  
      $file = "attachment/" . basename($_FILES['attachment']['name']);
      if (move_uploaded_file($_FILES['attachment']['tmp_name'], $file)) {
          if (sendemail('email@mail.net', $email, $name, $body, $file)) {
              $msg = 'Email sent!';
  
          } else
              $msg = 'Email failed!';
      } else
          $msg = "Please check your attachment!";
  }
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Contact&lt;/title&gt;
  &lt;/head&gt;
  &lt;style type="text/css"&gt;
      input, textarea {
          width:250px;
          height: 27px;
          margin-bottom: 10px;
      }
  
      textarea {
          height: 200px;
          width: 100%;
          resize: vertical;
      }
  
      body {
          text-align: center;
          margin-top: 250px;
      }
  &lt;/style&gt;
  &lt;body&gt;
      &lt;img src="images/logo.png"&gt;&lt;br&gt;&lt;br&gt;
      &lt;form method="post" action="index.php" enctype="multipart/form-data"&gt;
          &lt;input type="text"  name="username" placeholder="Name..." required&gt;&lt;br&gt;
          &lt;input type="email" name="email" placeholder="Email..." required&gt;&lt;br&gt;
          &lt;textarea name="body" placeholder="Message..." required&gt;&lt;/textarea&gt;&lt;br&gt;
          &lt;input type="file" name="attachment" required&gt;&lt;br&gt;
          &lt;input type="submit" name="submit" value="Send Email"&gt;
      &lt;/form&gt;
      &lt;br&gt;&lt;br&gt;
      &lt;?php echo $msg; ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>