Wednesday, June 18, 2014

html formatted contact form with attachment link

If you are looking for a contact form which can send html formatted email to the recipient and if you have little bit knowledge about php you can try this html contact form with attachment link. it will send a html formatted  to the recipient.

HTML CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="" content="">
</head>
<body>
<form method="POST" action="attachmail.php" enctype="multipart/form-data">
<table>
<tr>
<td>Nname</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"/></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" name="phone"/></td>
</tr>
<tr>
<td>message</td>
<td><textarea name="comments" id="comments" class="field" tabindex="6"></textarea></td>
</tr>
<tr>
<td>select a file*</td>
<td><input name="file" id="file" type="file" tabindex="7"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="submit"/></td>
</tr>
</table>
</form>
</body>

</html>

php attachment.php

<?php
$to = "someone@reciver.com"; //change recivers email address
$from = $_POST['email'];
$subject = "attachment mail"; //change subject
$headers          = 'MIME-Version: 1.0' . "\r\n";
$headers         .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers         .= "From: The Sender $from" . "\r\n";

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$imglink = $_FILES["file"]["name"];

$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 200000000)
&& in_array($extension, $allowedExts)) {
  if ($_FILES["file"]["error"] > 0) {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
  } else {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    if (file_exists("upload/" . $_FILES["file"]["name"])) {
      echo $_FILES["file"]["name"] . " already exists. ";
    } else {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      $message = "<html>
<body>
<p><strong>Name:</strong> <br>$name</p>
<p><strong>Phone:</strong> <br>$phone</p>
<p><strong>Email:</strong> <br>$email</p>
<p><strong>Quote Information</strong> <br>$comments</p>
<p><strong>Submitted Files</strong></p>
<hr>
<a href='upload/$imglink'>$imglink</a>
</body>
</html>";
    }
  }
} else {
  echo "Invalid file";
}



mail($to,$subject,$message,$headers);

?>

Related Posts:

  • can not login to magento after installation Hi guys if you can not login to magento admin panel after installation it's not an issue. All what you need to do is you will have to modify up a file of magento. Go to: app\code\core\Mage\Core\Model\Session\Abstr… Read More
  • Paypal Error (35) error 14094410: SSLV3 zencart If you are using zencart 1.5.1 and payment getway as paypal then you might get a error message Paypal Error (35) error 14094410: SSLV3. This is acctually because of update from paypal you can see the SSLV3 paypal update her… Read More
  • why choose worpress as your cms platform Most of designers and developers love wordpress as a cms systems there are may reasons behind it. Open source: Wordpress is a opensource cms. It is free to download and use. It has a huge helpful community by … Read More
  • html formatted contact form with attachment link If you are looking for a contact form which can send html formatted email to the recipient and if you have little bit knowledge about php you can try this html contact form with attachment link. it will send a html formatted… Read More
  • [Solved] How To Import Export Product in Magento? Well i had scenario that i have upload all the product and categories on my local host Magento store now what i had to is to make the website live and i had configured it live but the challenge came to me is i have to upload… Read More

0 comments:

Post a Comment