title: How do i add the ability to attach a file on a online mailer in PHP?
body: <p>I've been now searching to find out this for a long time, but couldn't find a exact answer on my specific question.</p>
  
  <p>And it goes like this: How do i add the possibility to attach a file to a online emailer I've written in PHP? :)</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;?php 
  session_start();
  
  if( isset($_POST['submit'])) 
  {
       if( $_SESSION['security_code'] == $_POST['security_code'] &amp;&amp; !empty($_SESSION['security_code'] ) ) 
         {  
         $to=$_POST["to"];
         $from=$_POST["from"];
         $name=$_POST["name"];
         $subject=$_POST["subject"];
         $message=$_POST["message"];
         $message=$message."\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
         $head="From: ".$from."\r\n".'Reply-To: '.$From."\r\n";
         $her=$head.' &lt; '.$from.' &gt;';
         $techomag=mail($to, $subject, $message, $her);
         echo "Your Message Has been send successfully...:)..";
             unset($_SESSION['security_code']);
        echo( '&lt;a href="mysite.com/index.php"&gt;Click here to send another email&lt;/a&gt;' );
        } 
        else 
        {
  
          echo 'Sorry, you have provided an invalid captcha security code :(...';
          echo( '&lt;a href="mysite.com/index.php"&gt;Click here to Go back and try once more&lt;/a&gt;' );
        }
  
  } 
  else 
  {
  ?&gt;
  &lt;?php
  ?&gt;
  
  
  &lt;div style="height:10px; clear:both"&gt;&lt;/div&gt;
  
  &lt;form action="index.php" method="post"&gt;
     &lt;table border="1"&gt;&lt;tbody&gt;
     &lt;tr&gt;&lt;td&gt;To Email :&lt;/td&gt;&lt;td&gt;&lt;input name="to" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;From Email :&lt;/td&gt;&lt;td&gt;&lt;input name="from" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;From Name :&lt;/td&gt;&lt;td&gt;&lt;input name="name" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;Subject :&lt;/td&gt;&lt;td&gt;&lt;input name="subject" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;Message :&lt;/td&gt;&lt;td&gt;&lt;textarea cols="30" rows="10" name="message"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;tr&gt;&lt;td&gt;&lt;img src="CaptchaSecurityImages.php?width=100&amp;height=40&amp;characters=5" /&gt;&lt;br /&gt;
     &lt;label for="security_code"&gt;Security Code: &lt;/label&gt;&lt;input id="security_code" name="security_code" type="text" /&gt;
     &lt;input type="submit" name="submit" value="Send Email!" /&gt;&lt;/td&gt;&lt;/tr&gt;
     &lt;/tbody&gt;&lt;/table&gt;
  &lt;/form&gt;
  
  &lt;?php
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Thank you from me :)</p>