I was wondering if anyone could help me. I am have made a very simple html form that uses php to email the data collected. What I am trying to do is have an upload attachment in the form, and have this also sent in the email. I have tried a few things, but nothing seems to work. This is waht I have so far:
In my html form:
[code]
Please fill out the form and we will endeavour to get back to you as soon as possible.
<span class="style7">.</span></p> </td>
</tr>
<tr>
<td colspan="2"><table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<?php include("send_contact_MAW_001.php"); ?>
<?
switch ($action) {
case “send”:
sendMail();
showForm();
break;
default:
showForm();
}
?>
[/code]
and in my php handeller:
[code]
Name |
: |
|
: |
||
Phone | : | |
Subject | : |
|
Industry | : | |
Attachment | : | |
Enquiry | : |
|
<? } function sendMail() { Oops! You forgot to fill out the email address! Click on the back arrow to go back ”);} else { $Name = stripslashes($_POST[‘Name’]); $Subject = stripslashes($_POST[‘Subject’]); $Phone = stripslashes($_POST[‘Phone’]); $Industry = stripslashes($_POST[‘Industry’]); $Enquiry = stripslashes($_POST[‘Enquiry’]); $Email = $_POST[‘Email’]; $Attachment = $_FILES[‘Attachment’][‘tmp_name’]; $attachment_name = $_FILES[‘attachment’][‘name’]; if (is_uploaded_file($attachment)) { //Do we have a file uploaded? $fp = fopen($attachment, “rb”); //Open it $data = fread($fp, filesize($attachment)); //Read it $data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed fclose($fp); } //Let’s start our headers $headers = “From: $Name<” . $_POST[‘Email’] . “>n”; $headers .= “Reply-To: <” . $_POST[‘Email’] . “>n”; $headers .= “MIME-Version: 1.0n”; $headers .= “Content-Type: multipart/related; type=“multipart/alternative”; boundary=”----=MIME_BOUNDRY_main_message"n"; $headers .= “X-Sender: $Name<” . $_POST[‘Email’] . “>n”; $headers .= “X-Mailer: PHP4n”; $headers .= “X-Priority: 3n”; //1 = Urgent, 3 = Normal $headers .= “Return-Path: <” . $_POST[‘Email’] . “>n”; $headers .= “This is a multi-part message in MIME format.n”; $headers .= “------=MIME_BOUNDRY_main_message n”; $headers .= “Content-Type: multipart/alternative; boundary=”----=MIME_BOUNDRY_message_parts"n";
} print <<< EOT <?xml version="1.0" encoding="iso-8859-1"?>
Any help would be greatly appreciated |