What I'm trying to do is on the website, create a form which will get their name (first and last) along with why they're sending the message and having them have the option of uploading a file from the computer and attaching it to the e-mail.
Here is the HTML:
Here is part of the thankyou.php file:Code:<h1>Contact</h1> <form enctype="multipart/form-data" action="thankyou.php" method="post"> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" /><br /> <label for="reason">Reason For Contacting Us:</label> <select name="Reason For Contacting Us:"> <option id="reason" value="donate">Donate</option> <option id="reason" value="internship">Internship</option> <option id="reason" value="volunteer">Volunteer</option> <option id="reason" value="comments">Comments/Suggestions</option> <option id="reason" value="other">Other</option> </select> <br /> <textarea name="message" style="width: 100%; height: 150px;"></textarea> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <label for="attachment">Attachment:</label> <input name="uploadedfile" type="file" /><br /> <input name="Submit" type="submit" value="Send" /> <input name="Reset" type="reset" value="Reset" /> </form>
I got this code from:Code:<h1>Thank You!</h1> <?php $to = 'a.shipley22@gmail.com'; $email = $_POST['email']; $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $reason = $_POST['reason']; $message = $_POST['message']; //Gather file data and other things $attachment = $_FILES['sample']['tmp_name']; $sep = md5(time()); $filename = $_FILES['sample']['name']; $filedata = file_get_contents($tmp); //Get file contents $fdata = chunk_split(base64_encode($filedata)); //Encode data into text form //Determine mime type $ext = explode('.', $filename); $ext = $ext[1]; if($ext == "JPG" || $ext == "jpg" || $ext == "JPEG" || $ext == "jpeg") { $mime_type = "image/jpeg"; } elseif($ext == "gif" || $ext == "GIF") { $mime_type = "image/gif"; } elseif($ext == "png" || $ext =="PNG") { $mime_type = "image/png"; } elseif($ext == "pdf" || $ext == "PDF") { $mime_type == "application/pdf"; } elseif($ext == "doc" || $ext == "DOC" || $ext == "docx" || $ext == "DOCX") { $mime_type = "application/msword"; } else { exit("Error: Wrong file type!"); } //Begin the headers $headers = "MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary=\"$sep\" charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit --$sep Content-Type: $mime_type; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"$filename\" $fdata --$sep"; mail($to, 'SmileHealthy Form: ' . $reason, $message, $headers); echo 'Thank you ' . $firstname . ' ' . $lastname . ' for submitting this form.<br />'; echo 'Your e-mail address is ' . $email; ?>
http://www.knowledgesutra.com/forums...il-attachment/
Any help is appreciated!Thank you.



Thank you.
Reply With Quote

Bookmarks