...

View Full Version : Form mail attachment not working



teampandu
10-21-2009, 07:24 PM
Greetings,

Can some help me to add files (.PDF and .DOC) as attachment to form.

Below is the working code without attachment option.

My HTML Form


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="form-styles.css"/>
<title>Untitled Document</title>
</head>
<body>
<div id="FormCont">
<form method="POST" name="consult" id="consult" action="01.php" enctype="multipart/form-data">
<label class="LabelInpTxtField">Name of the company:</label>
<input type="text" name="CompName" class="InpTxtFiled" id="CompName" />
<label class="LabelInpTxtField">Address:</label>
<textarea name="Address" id="Address" class="AddTxtArea"></textarea>
<label class="LabelInpTxtField">City:</label>
<input type="text" name="City" id="City" class="InpTxtFiled" />
<label class="LabelInpTxtField">Pincode:</label>
<input type="text" name="Pincode" id="Pincode" class="InpTxtFiled" />
<label class="LabelInpTxtField">State:</label>
<input type="text" name="State" id="State" class="InpTxtFiled" />
<label class="LabelInpTxtField">Telephone No:</label>
<input type="text" name="TelephoneNo" id="TelephoneNo" class="InpTxtFiled" />
<label class="LabelInpTxtField">Mobile No.:</label>
<input type="text" name="MobileNo" id="MobileNo" class="InpTxtFiled" />
<label class="LabelInpTxtField">Fax No.:</label>
<input type="text" name="FaxNo" id="FaxNo" class="InpTxtFiled" />
<label class="LabelInpTxtField">Email ID:</label>
<input type="text" name="EmailID" id="EmailID" class="InpTxtFiled" />
<label class="LabelInpTxtField">Website URL:</label>
<input type="text" name="WebsiteURL" id="WebsiteURL" class="InpTxtFiled" />
<label class="LabelInpTxtField">Contact person:</label>
<input type="text" name="ContactPerson" id="ContactPerson" class="InpTxtFiled" />
<div class="ChoicesCont">
<label class="LabelInpTxtField" style="height:160px;">Company type:</label>
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Proprietary" />
Proprietary</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Partnership" />
Partnership</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Pvt. Ltd" />
Pvt. Ltd</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Public Ltd" />
Public Ltd</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="SSI" />
SSI</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Dealer" />
Dealer</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Manufacturer" />
Manufacturer</label>
<br />
<label>
<input type="radio" name="CompanyType" id="CompanyType" value="Others" />
Others</label>
<br />
</div>
<div class="ChoicesCont">
<label class="LabelInpTxtField">TDS Application:<br />
<span class="small">(Tax Payee or not)</span> </label>
<label>
<input type="radio" name="TDS" id="TDS1" value="Yes" />
Yes</label>
<br />
<label>
<input type="radio" name="TDS" id="TDS2" value="No" />
No</label>
<br />
</div>
<label class="LabelInpTxtField">Income Tax PAN No:</label>
<input type="text" name="IncomeTaxPANNo" id="IncomeTaxPANNo" class="InpTxtFiled" />
<label class="LabelInpTxtField">Service Tax No.:</label>
<input type="text" name="ServiceTaxNo" id="ServiceTaxNo" class="InpTxtFiled" />
<div class="ChoicesCont">
<label class="LabelInpTxtField" style="height:125px;">Type of consultant:</label>
<label>
<input type="checkbox" name="Type_Consult1" id="Type_Consult1" value="Civil" />
Civil</label>
<br />
<label>
<input type="checkbox" name="Type_Consult2" id="Type_Consult2" value="Electrical" />
Electrical</label>
<br />
<label>
<input type="checkbox" name="Type_Consult3" id="Type_Consult3" value="Plumbing" />
Plumbing</label>
<br />
<label>
<input type="checkbox" name="Type_Consult4" id="Type_Consult4" value="HVAC" />
HVAC</label>
<br />
<label>
<input type="checkbox" name="Type_Consult5" id="Type_Consult5" value="Landscape" />
Landscape</label>
<br />
<label>
<input type="checkbox" name="Type_Consult6" id="Type_Consult6" value="Interiors" />
Interiors</label>
<br />
<label>Others
<input type="text" name="Others" id="Others" />
</label>
<br />
</div>
<label class="LabelInpTxtField">Company details: </label>
<input type="file" name="uploaded_file" id="datafile" class="InpTxtFiled">
<p class="destxt">(Please attach Word/PDF/Excel Document containing Company Profile, Organisational Chart, Strength of the Company, List of Key Persons with Details, Name of Client with Project completed and Area and Name of current Client with Name and Area)</p>
<label class="LabelInpTxtField">Reference:</label>
<textarea name="Reference" id="Reference" class="AddTxtArea" ></textarea>
<div class="secureInputText" align="center"> For verification, type the characters shown below.</div>
<div align="center"> <img src="captchac.php" alt=""/>
<input name="6_letters_code" type="text" class="formInputText" id="6_letters_code" size="7" value="Type here" onfocus="if (this.value == 'Type here') {this.value = ''; }" onblur="if (this.value == '') { this.value = 'Type here'; }" />
</div>
<div align="center">
<input type="submit" value="Send us" />
<input type="reset" />
</div>
</form>
</div>
</body>
</html>

PHP Code


<?php
ini_set ("SMTP","mailhub.atl.registeredsite.com");
ini_set ("sendmail_from","harish@resourcedesign.co.in");
session_start();
if( $_SESSION['6_letters_code'] == $_POST['6_letters_code'] && !empty($_SESSION['6_letters_code'] ) ) {

$to = "pandu@resourcedesign.co.in";
// $bcc="";
$email_subject = "Consultats Registration";
$CompName = $_POST['CompName'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$Pincode = $_POST['Pincode'];
$State = $_POST['State'];
$TelephoneNo = $_POST['TelephoneNo'];
$MobileNo = $_POST['MobileNo'];
$FaxNo = $_POST['FaxNo'];
$EmailID = $_POST['EmailID'];
$WebsiteURL = $_POST['WebsiteURL'];
$ContactPerson = $_POST['ContactPerson'];
$CompanyType = $_POST['CompanyType'];
$TDS = $_POST['TDS'];
$IncomeTaxPANNo = $_POST['IncomeTaxPANNo'];
$ServiceTaxNo = $_POST['ServiceTaxNo'];
$Type_Consult1 = $_POST['Type_Consult1'];
$Type_Consult2 = $_POST['Type_Consult2'];
$Type_Consult3 = $_POST['Type_Consult3'];
$Type_Consult4 = $_POST['Type_Consult4'];
$Type_Consult5 = $_POST['Type_Consult5'];
$Type_Consult6 = $_POST['Type_Consult6'];
$Others = $_POST['Others'];
$Reference = $_POST['Reference'];

$email_body = '<html>
<head>
<title>Brigade Group</title>
</head>
<style type="text/css">
<!--
.D {
font-size: 12px;
font-family:Arial, Helvetica, sans-serif;
}
-->
</style>
<br /><br />
<table width="450" border="0" cellpadding="4" cellspacing="0">
<tr>
<td height="25" colspan="3" align="center" class="D"><strong> CONSULTANTS&nbsp; DETAILS
</strong></td>
</tr>
<tr>
<td width="226" bgcolor="#F4F4F4">Name of the company</td>
<td width="8" bgcolor="#F4F4F4"><span class="D">:</span></td>
<td width="192" bgcolor="#F4F4F4"><strong><span class="D">'.$CompName.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Address</td>
<td bgcolor="#DFDFDF"><span class="D">:</span></td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$Address.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">City</td>
<td bgcolor="#F4F4F4"><span class="D">:</span></td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$City.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Pincode</td>
<td bgcolor="#DFDFDF"><span class="D">:</span></td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$Pincode.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">State</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$State.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Telephone No</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$TelephoneNo.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Mobile No</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$MobileNo.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Fax No</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$FaxNo.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Email ID</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$EmailID.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Website URL</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$WebsiteURL.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Contact person</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$ContactPerson.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Company type</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$CompanyType.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">TDS Application (Tax Payee or not)</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$TDS.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Income Tax PAN No</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$IncomeTaxPANNo.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Service Tax No</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4"><strong><span class="D">'.$ServiceTaxNo.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Type of consultant</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><span class="D">'.$Type_Consult1.'<br />'.$Type_Consult2.'<br />'.$Type_Consult3.'<br />'.$Type_Consult4.'<br />'.$Type_Consult5.'<br />'.$Type_Consult6.'</span></td>
</tr>
<tr>
<td bgcolor="#DFDFDF">&nbsp;</td>
<td bgcolor="#DFDFDF">&nbsp;</td>
<td bgcolor="#DFDFDF">Others: <strong><span class="D">'.$Others.'</span></strong></td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Company details</td>
<td bgcolor="#F4F4F4">:</td>
<td bgcolor="#F4F4F4">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#DFDFDF">Reference</td>
<td bgcolor="#DFDFDF">:</td>
<td bgcolor="#DFDFDF"><strong><span class="D">'.$Reference.'</span></strong></td>
</tr>
</table>
</body>
</html>';
mail($to, $email_subject, $email_body, "From: \"$CompName\" <$EmailID>\nReply-To: \"$CompName\" <$EmailID>\nX-Mailer: chfeedback.php 2.01\nContent-Type: text/html; charset=iso-8859-1");
echo "<center>Your message is successfully emailed.</center>";
$webDoc = DOMDocument::loadHTMLFile("thankyou.htm");
print $webDoc->saveHTML();
} else {
echo "Sorry, you have provided an invalid security code. Please <a href='#' onClick='history.go(-1);return true;'>CLICK HERE</a> to try again.";
}
?>

abduraooft
10-23-2009, 10:11 AM
I'd recommend you to use PHPMaile (http://phpmailer.worxware.com/)r, which will make the things much easier.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum