Thursday, October 24, 2019

Form attachment send to Email using php


 <?php
    if(isset($_POST['submit_btn']))
    {
     
   
      $to = 'info@abc.com';
        //$to = 'pardeep@gmail.com';
        $subject = $_POST['ur_name'].' - Subject here';

        $message = 'Product Name: '. strip_tags($_POST['product_name']);
        $message1 = 'Product Color: '.strip_tags($_POST['product_color']);
        $message2 = 'Imprint Color: '.strip_tags($_POST['imprint_color']);
       // $message = strip_tags($_POST['upload_logo']);
        $message3 = 'Name: '.strip_tags($_POST['ur_name']);
        $message4 ='Email: '. strip_tags($_POST['ur_email']);
        $message5 = 'Company Name: '.strip_tags($_POST['company_name']);
        $message6 = 'Phone Number: '.strip_tags($_POST['phone_number']);
        $message7 = 'Comment: '.strip_tags($_POST['coment']);
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['upload_logo']['tmp_name'])));
        $filename = $_FILES['upload_logo']['name'];

       

        $boundary =md5(date('r', time()));

        $headers = "From: info@bodimasta.com.au";
        $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
                                                               
        $message="This is a multi-part message in MIME format.

--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"

--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit

$message\n$message1\n$message2\n$message3\n$message4\n$message5\n$message6\n$message7\n

--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

$attachment
--_1_$boundary--";

        mail($to, $subject, $message, $headers);
     
         echo '<script type="text/javascript">alert("Thank you! Your message has been sent.");</script>';
    }
?>


<form action="" method="post" class="tbldesigns" name="artwork_mockup" enctype="multipart/form-data">
<div class="main1">
<div class="container_drsc">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<label class="col-sm-12 titleserd">Product</label>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> Name</label>
<div class="col-sm-10 col-xs-12">
<input type="text" id="pjCF_field_229" name="product_name" value="" required size="30" class="form-control pjCF-form-field pjCF-checked-field" placeholder="">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> Product Color</label>
<div class="col-sm-10 col-xs-12">
<input type="text" id="pjCF_field_229" name="product_color" value="" size="30" class="form-control pjCF-form-field pjCF-checked-field" placeholder="" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> Color</label>
<div class="col-sm-10 col-xs-12">
<input type="text" id="pjCF_field_229" name="imprint_color" value="" size="30" class="form-control pjCF-form-field pjCF-checked-field" placeholder="">
</div>
</div>

</div>
</div>
</div>

<div class="container_drsc">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<label class="col-sm-12 titleserd">Upload Logo</label>
</div>
<div class="form-group">
<div class="wide- fileupload-cover field-cover">
          <label class="col-sm-2 control-label">Attach Your Logo</label>
  <div class="col-sm-10 col-xs-12">
<div class="acd">
</div-->
<input class="filuplod" type="file" data-name-list="field15" name="upload_logo">
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="container_drsc">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<label class="col-sm-12 cf-heading cf-heading-medium titleserd"> Your Contact Details</label>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Name</label>
<div class="col-sm-10 col-xs-12">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"> </i></span>
<input id="name" type="text" class="form-control" name="ur_name" placeholder="Name" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Email</label>
<div class="col-sm-10 col-xs-12">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"> </i></span>
<input id="email" type="text" class="form-control" name="ur_email" placeholder="Email" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Company Name</label>
<div class="col-sm-10 col-xs-12">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"> </i></span>
<input id="company name" type="text" class="form-control" name="company_name" placeholder="Company Name">
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Phone Number</label>
<div class="col-sm-10 col-xs-12">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"> </i></span>
<input id="phone number" type="text" class="form-control" name="phone_number" placeholder="Phone Number" required>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Comments</label>
<div class="col-sm-10 col-xs-12">
<div class="input-group1">

<textarea rows="4" cols="70" class="form-control" name="coment" Placeholder="Comments...."></textarea>
</div>
</div>
</div>
</div>
<div class="col-sm-12 bthsd text-center">
<button type="submit" class="submit_btn" value="Submit Form" name="submit_btn"> Submit </button>
</div>

</div>
</div>
</div>
</div>

   </div>
         </form>

No comments:

Post a Comment