aladiyat23 Posted July 21, 2006 Share Posted July 21, 2006 I really need help with this php script. I get no errors after submitting and the user is taken to the confirmation page. I'm sent an email with the input field info but no attachment. I'd appreciate any help while I learn this stuff.[color=red]here's my php file[/color]<?php if(isset($_POST['submit'])){ $to = "xxx"; $subject = "Data Request"; $email = $_POST['requiredemail']; $name = $_POST['requireddealername']; $address = $_POST['requiredaddress']; $zip = $_POST['requiredzip']; $quanity = $_POST['requiredquanity']; $list = $_POST['requiredlist']; $range = $_POST['range']; $year = $_POST['year']; $make = $_POST['make']; $other = $_POST['other']; $headers = "From: $email \r\n"; $fileatt = $_FILES['uploadedfile']['tmp_name']; $fileatt_type = $_FILES['uploadedfile']['type']; $fileatt_name = $_FILES['uploadedfile']['name']; if (is_uploaded_file($fileatt)) { $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $data = chunk_split(base64_encode($data)); $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";} $body = " From: $email\n Dealer Name: $name\n Address: $address\n Zip: $zip\n Quanity: $quanity\n List: $list\n Range: $range\n Year: $year\n Make: $make\n Other: $other\n"; mail($to, $subject, $body, $headers); echo '<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://www.dmmipromotions.com/submission.html">'; } else { echo "An error has occured. Please fill out the form and try again";}?>[color=red]Here's partial html[/color]<form onsubmit="return checkrequired(this)" ENCTYPE="multipart/form-data" method="post" action="xxx"><input class="formfield-data" name="uploadedfile" type="file" size="30" /><input name="submit" type="submit" class="formfield-data" value="Upload & Submit" onclick="LimitAttach(this.form, this.form.attachment.value)"/></form>I'd really really appreciate any tips or help with this. If I left anything out to help you help me just let me know ;)Thank you Link to comment https://forums.phpfreaks.com/topic/15206-email-form-with-attachment/ Share on other sites More sharing options...
hitman6003 Posted July 21, 2006 Share Posted July 21, 2006 User phpmailer...it makes sending email very easy.http://phpmailer.sourceforge.net/ Link to comment https://forums.phpfreaks.com/topic/15206-email-form-with-attachment/#findComment-61447 Share on other sites More sharing options...
aladiyat23 Posted July 21, 2006 Author Share Posted July 21, 2006 Thanks for the reply hitman, but i'd like to learn why the code i posted isnt attaching the uploaded document into the emails. I'm really hoping to grasp php so maybe when I'm comfortable working with it I'll take an easier route like phpmailer. Thanks :) Link to comment https://forums.phpfreaks.com/topic/15206-email-form-with-attachment/#findComment-61623 Share on other sites More sharing options...
aladiyat23 Posted July 21, 2006 Author Share Posted July 21, 2006 okay, so is this just too hard to get help on? is it that far off that its beyond script advice? Link to comment https://forums.phpfreaks.com/topic/15206-email-form-with-attachment/#findComment-61692 Share on other sites More sharing options...
watts Posted September 28, 2006 Share Posted September 28, 2006 I can't answer why your code isn't working but using phpmailer doesn't stop you from learning php. It's just a class that has been created to make it easier to send email and allows you to do things that can be quite complicated using just the php mail() class. I would check out the site and see what you think before you dismiss it.Watts Link to comment https://forums.phpfreaks.com/topic/15206-email-form-with-attachment/#findComment-100460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.