Jump to content

didster

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Everything posted by didster

  1. Hi thanks for the quick replies! I can send a small text file and that seems to work but pdfs or jpgs dont send properly, just the filename. I am only a beginner so I will look into Pear, cheers guys
  2. Hello, Could someone please have a look at my code. I have tried on several forums now, everyone looks at it but dont give me any advice. I am hoping this time, I might be in luck I have no idea what the problem is with it. I altered an existing webform so that I could add attachments including text/images/pdf files. The email works with the attachment but the attachment has zero content. Please please please could someone try and fix it and explain what I am doing wrong. <?php //error_reporting(E_ALL); //ini_set("display_errors", 1); // ------------- CONFIGURABLE SECTION ------------------------ $to = '' ; $subject = "Plug Gauge Quote Request Form" ; $formurl = "/enquiryform/pluggauge.htm"; $errorurl = "/enquiryform/error.htm" ; $thankyouurl = "/enquiryform/thankyou.htm" ; // -------------------- END OF CONFIGURABLE SECTION --------------- $contactname = $_POST['contactname'] ; $companyname = $_POST['companyname'] ; $currentaddress = $_POST['currentaddress'] ; $contactnumber = $_POST['contactnumber'] ; $rfqreference = $_POST['rfqreference'] ; $teeth = $_POST['teeth'] ; $dpmoduletext = $_POST['dpmoduletext'] ; $dpmoduledrop = $_POST['dpmoduledrop'] ; $pressureangle = $_POST['pressureangle'] ; $helixangle = $_POST['helixangle'] ; $helixhand = $_POST['helixhand'] ; $pitchtext = $_POST['pitchtext'] ; $pitchdrop = $_POST['pitchdrop'] ; $gauge = $_POST['gauge'] ; $typefit = $_POST['typefit'] ; $facetext = $_POST['facetext'] ; $facedrop = $_POST['facedrop'] ; $quantity = $_POST['quantity'] ; $materials = $_POST['materials'] ; $notes = $_POST['notes'] ; $chknotest = $_POST['chkno'] ; // Read POST request params into global vars $from = $_POST['from']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; } if (!empty($companyname)) { $message .= "\n\n-- Company Name --\n\n" . $companyname; } if (!empty($currentaddress)) { $message .= "\n\n-- Current Address --\n\n" . $currentaddress; } if (!empty($contactnumber)) { $message .= "\n\n-- Contact Number --\n\n" . $contactnumber; } if (!empty($rfqreference)) { $message .= "\n\n-- RFQ Reference Number --\n\n" . $rfqreference; } if (!empty($teeth)) { $message .= "\n\n-- Teeth --\n\n" . $teeth; } if (!empty($dpmoduletext)) { $message .= "\n\n-- DP Module Text --\n\n" . $dpmoduletext; } if (!empty($dpmoduledrop)) { $message .= "\n\n-- DP Module Drop --\n\n" . $dpmoduledrop; } if (!empty($pressureangle)) { $message .= "\n\n-- Pressure Angle --\n\n" . $pressureangle; } if (!empty($helixangle)) { $message .= "\n\n-- Helix Angle --\n\n" . $helixangle; } if (!empty($helixhand)) { $message .= "\n\n-- Helix Hand --\n\n" . $helixhand; } if (!empty($pitchtext)) { $message .= "\n\n-- Pitch Text (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchtext; } if (!empty($pitchdrop)) { $message .= "\n\n-- Pitch Drop (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchdrop; } if (!empty($gauge)) { $message .= "\n\n-- Gauge Ref/Tool No. --\n\n" . $gauge; } if (!empty($typefit)) { $message .= "\n\n-- Type Fit --\n\n" . $typefit; } if (!empty($facetext)) { $message .= "\n\n-- Face Width Text --\n\n" . $facetext; } if (!empty($facedrop)) { $message .= "\n\n-- Face Width Drop --\n\n" . $facedrop; } if (!empty($quantity)) { $message .= "\n\n-- Quantity --\n\n" . $quantity; } if (!empty($materials)) { $message .= "\n\n-- Materials --\n\n" . $materials; } if (!empty($notes)) { $message .= "\n\n-- Notes --\n\n" . $notes; } // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $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"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $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"; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['from'])) { header( "Location: $formurl" ); exit ; } if (empty($contactname) || empty($from) || empty($companyname) || empty($contactnumber) || empty($teeth) || empty($quantity) || empty($chknotest)) { header( "Location: $errorurl" ); exit ; } $contactname = strtok( $contactname, "\r\n" ); $email = strtok( $email, "\r\n" ); if (get_magic_quotes_gpc()) { $chkno = stripslashes( $chkno ); $companyname = stripslashes( $companyname ); $currentaddress = stripslashes( $currentaddress ); $contactnumber = stripslashes( $contactnumber ); $rfqreference = stripslashes( $rfqreference ); $teeth = stripslashes( $teeth ); $dpmoduletext = stripslashes( $dpmoduletext ); $dpmoduledrop = stripslashes( $dpmoduledrop ); $pressureangle = stripslashes( $pressureangle ); $helixangle = stripslashes( $helixangle ); $helixhand = stripslashes( $helixhand ); $pitchtext = stripslashes( $pitchtext ); $pitchdrop = stripslashes( $pitchdrop ); $gauge = stripslashes( $gauge ); $typefit = stripslashes( $typefit ); $facetext = stripslashes( $facetext ); $facedrop = stripslashes( $facedrop ); $quantity = stripslashes( $quantity ); $materials = stripslashes( $materials ); $notes = stripslashes( $notes ); } ini_set("sendmail_from", $from); mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" ); exit ; ?>
  3. Please can anyone help with this, I am pulling my hair out. I can upload and send a text file cant send pdf or jpg files. The files send but do not have any content in them! Please help <?php //error_reporting(E_ALL); //ini_set("display_errors", 1); // ------------- CONFIGURABLE SECTION ------------------------ $to = '' ; $subject = "" ; $formurl = "/enquiryform/pluggauge.htm"; $errorurl = "/enquiryform/error.htm" ; $thankyouurl = "/enquiryform/thankyou.htm" ; // -------------------- END OF CONFIGURABLE SECTION --------------- // Read POST request params into global vars $from = $_POST['from']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $message .= "\n\n-- Email recieved --\n\n"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $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"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $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"; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['from'])) { header( "Location: $formurl" ); exit ; } if (empty($from)) { header( "Location: $errorurl" ); exit ; } $email = strtok( $email, "\r\n" ); ini_set("sendmail_from", $from); mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" ); exit ; ?>
  4. Hello, I am struggling to see why my email wont send properly. The attachment arrives without any content in it but only on certain servers. My server is fine! I have tested another script what I found and the attachment sends correctly but the attachment process is different. The first lot of code works but the second doesnt. Please can someone point me in the right direction. Am I just missing something simple? <?PHP $to = ''; $subject = 'PHP Mail Attachment Test'; $bound_text = "jimmyP123"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: admin@server.com\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" ."Content-Transfer-Encoding: 7bit\r\n\r\n" ."hey my <b>good</b> friend here is a picture of regal beagle\r\n" .$bound; $file = file_get_contents("http://www.litfuel.net/php/regal_004.jpg"); $message .= "Content-Type: image/jpg; name=\"regal_004.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"regal_004.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; if(mail($to, $subject, $message, $headers)) { echo 'MAIL SENT'; } else { echo 'MAIL FAILED'; } ?> <?php $to = '' ;// $subject - set to the Subject line of the email, eg //$subject = "Feedback Form" ; $subject = "Plug Gauge Quote Request Form" ; //$thankyouurl = "http://www.paulfenlon.com/thankyou.html" ; $formurl = "/enquiryform/pluggauge.htm"; $errorurl = "/enquiryform/error.htm" ; $thankyouurl = "/enquiryform/thankyou.htm" ; // -------------------- END OF CONFIGURABLE SECTION --------------- $contactname = $_POST['contactname'] ; $companyname = $_POST['companyname'] ; $currentaddress = $_POST['currentaddress'] ; $contactnumber = $_POST['contactnumber'] ; $rfqreference = $_POST['rfqreference'] ; $teeth = $_POST['teeth'] ; $dpmoduletext = $_POST['dpmoduletext'] ; $dpmoduledrop = $_POST['dpmoduledrop'] ; $pressureangle = $_POST['pressureangle'] ; $helixangle = $_POST['helixangle'] ; $helixhand = $_POST['helixhand'] ; $pitchtext = $_POST['pitchtext'] ; $pitchdrop = $_POST['pitchdrop'] ; $gauge = $_POST['gauge'] ; $typefit = $_POST['typefit'] ; $facetext = $_POST['facetext'] ; $facedrop = $_POST['facedrop'] ; $quantity = $_POST['quantity'] ; $materials = $_POST['materials'] ; $notes = $_POST['notes'] ; $chknotest = $_POST['chkno'] ; // Read POST request params into global vars $from = $_POST['from']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; } if (!empty($companyname)) { $message .= "\n\n-- Company Name --\n\n" . $companyname; } if (!empty($currentaddress)) { $message .= "\n\n-- Current Address --\n\n" . $currentaddress; } if (!empty($contactnumber)) { $message .= "\n\n-- Contact Number --\n\n" . $contactnumber; } if (!empty($rfqreference)) { $message .= "\n\n-- RFQ Reference Number --\n\n" . $rfqreference; } if (!empty($teeth)) { $message .= "\n\n-- Teeth --\n\n" . $teeth; } if (!empty($dpmoduletext)) { $message .= "\n\n-- DP Module Text --\n\n" . $dpmoduletext; } if (!empty($dpmoduledrop)) { $message .= "\n\n-- DP Module Drop --\n\n" . $dpmoduledrop; } if (!empty($pressureangle)) { $message .= "\n\n-- Pressure Angle --\n\n" . $pressureangle; } if (!empty($helixangle)) { $message .= "\n\n-- Helix Angle --\n\n" . $helixangle; } if (!empty($helixhand)) { $message .= "\n\n-- Helix Hand --\n\n" . $helixhand; } if (!empty($pitchtext)) { $message .= "\n\n-- Pitch Text (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchtext; } if (!empty($pitchdrop)) { $message .= "\n\n-- Pitch Drop (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchdrop; } if (!empty($gauge)) { $message .= "\n\n-- Gauge Ref/Tool No. --\n\n" . $gauge; } if (!empty($typefit)) { $message .= "\n\n-- Type Fit --\n\n" . $typefit; } if (!empty($facetext)) { $message .= "\n\n-- Face Width Text --\n\n" . $facetext; } if (!empty($facedrop)) { $message .= "\n\n-- Face Width Drop --\n\n" . $facedrop; } if (!empty($quantity)) { $message .= "\n\n-- Quantity --\n\n" . $quantity; } if (!empty($materials)) { $message .= "\n\n-- Materials --\n\n" . $materials; } if (!empty($notes)) { $message .= "\n\n-- Notes --\n\n" . $notes; } // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $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"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $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"; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['from'])) { header( "Location: $formurl" ); exit ; } if (empty($contactname) || empty($from) || empty($companyname) || empty($contactnumber) || empty($teeth) || empty($quantity) || empty($chknotest)/* || empty($dpmoduletext) || empty($dpmoduledrop) || empty($currentaddress) || empty($rfqreference) || empty($pressureangle) || empty($helixangle) || empty($helixhand) || empty($pitchtext) || empty($pitchdrop) || empty($gauge) || empty($typefit) || empty($facetext) || empty($facedrop) || empty($quantity) || empty($materials) ||empty($notes) */) { header( "Location: $errorurl" ); exit ; } $contactname = strtok( $contactname, "\r\n" ); $email = strtok( $email, "\r\n" ); if (get_magic_quotes_gpc()) { $chkno = stripslashes( $chkno ); $companyname = stripslashes( $companyname ); $currentaddress = stripslashes( $currentaddress ); $contactnumber = stripslashes( $contactnumber ); $rfqreference = stripslashes( $rfqreference ); $teeth = stripslashes( $teeth ); $dpmoduletext = stripslashes( $dpmoduletext ); $dpmoduledrop = stripslashes( $dpmoduledrop ); $pressureangle = stripslashes( $pressureangle ); $helixangle = stripslashes( $helixangle ); $helixhand = stripslashes( $helixhand ); $pitchtext = stripslashes( $pitchtext ); $pitchdrop = stripslashes( $pitchdrop ); $gauge = stripslashes( $gauge ); $typefit = stripslashes( $typefit ); $facetext = stripslashes( $facetext ); $facedrop = stripslashes( $facedrop ); $quantity = stripslashes( $quantity ); $materials = stripslashes( $materials ); $notes = stripslashes( $notes ); } ini_set("sendmail_from", $from); mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" ); exit ; ?>
  5. Hi, you may have seen this code before as I thought I was having problems with email. It turned out that it was the hosts fault! This problem is probably the same, I can now send email but any attachments added using the upload feature, send the attachment file but with no content. I have tried it on my own server and several others and is fine. Please help The phpinfo of the new server is... http://www.splinegauges.co.uk/phpinfo.php <?php // ------------- CONFIGURABLE SECTION ------------------------ $to = '' ;// $subject - set to the Subject line of the email, eg //$subject = "Feedback Form" ; $subject = "Plug Gauge Quote Request Form" ; $formurl = "/enquiryform/pluggauge.htm"; $errorurl = "/enquiryform/error.htm" ; $thankyouurl = "/enquiryform/thankyou.htm" ; // -------------------- END OF CONFIGURABLE SECTION --------------- $contactname = $_POST['contactname'] ; $companyname = $_POST['companyname'] ; $currentaddress = $_POST['currentaddress'] ; $contactnumber = $_POST['contactnumber'] ; $rfqreference = $_POST['rfqreference'] ; $teeth = $_POST['teeth'] ; $dpmoduletext = $_POST['dpmoduletext'] ; $dpmoduledrop = $_POST['dpmoduledrop'] ; $pressureangle = $_POST['pressureangle'] ; $helixangle = $_POST['helixangle'] ; $helixhand = $_POST['helixhand'] ; $pitchtext = $_POST['pitchtext'] ; $pitchdrop = $_POST['pitchdrop'] ; $gauge = $_POST['gauge'] ; $typefit = $_POST['typefit'] ; $facetext = $_POST['facetext'] ; $facedrop = $_POST['facedrop'] ; $quantity = $_POST['quantity'] ; $materials = $_POST['materials'] ; $notes = $_POST['notes'] ; $chknotest = $_POST['chkno'] ; // Read POST request params into global vars $from = $_POST['from']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; } if (!empty($companyname)) { $message .= "\n\n-- Company Name --\n\n" . $companyname; } if (!empty($currentaddress)) { $message .= "\n\n-- Current Address --\n\n" . $currentaddress; } if (!empty($contactnumber)) { $message .= "\n\n-- Contact Number --\n\n" . $contactnumber; } if (!empty($rfqreference)) { $message .= "\n\n-- RFQ Reference Number --\n\n" . $rfqreference; } if (!empty($teeth)) { $message .= "\n\n-- Teeth --\n\n" . $teeth; } if (!empty($dpmoduletext)) { $message .= "\n\n-- DP Module Text --\n\n" . $dpmoduletext; } if (!empty($dpmoduledrop)) { $message .= "\n\n-- DP Module Drop --\n\n" . $dpmoduledrop; } if (!empty($pressureangle)) { $message .= "\n\n-- Pressure Angle --\n\n" . $pressureangle; } if (!empty($helixangle)) { $message .= "\n\n-- Helix Angle --\n\n" . $helixangle; } if (!empty($helixhand)) { $message .= "\n\n-- Helix Hand --\n\n" . $helixhand; } if (!empty($pitchtext)) { $message .= "\n\n-- Pitch Text (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchtext; } if (!empty($pitchdrop)) { $message .= "\n\n-- Pitch Drop (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchdrop; } if (!empty($gauge)) { $message .= "\n\n-- Gauge Ref/Tool No. --\n\n" . $gauge; } if (!empty($typefit)) { $message .= "\n\n-- Type Fit --\n\n" . $typefit; } if (!empty($facetext)) { $message .= "\n\n-- Face Width Text --\n\n" . $facetext; } if (!empty($facedrop)) { $message .= "\n\n-- Face Width Drop --\n\n" . $facedrop; } if (!empty($quantity)) { $message .= "\n\n-- Quantity --\n\n" . $quantity; } if (!empty($materials)) { $message .= "\n\n-- Materials --\n\n" . $materials; } if (!empty($notes)) { $message .= "\n\n-- Notes --\n\n" . $notes; } // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $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"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $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"; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['from'])) { header( "Location: $formurl" ); exit ; } if (empty($contactname) || empty($from) || empty($companyname) || empty($contactnumber) || empty($teeth) || empty($quantity) || empty($chknotest)/* || empty($dpmoduletext) || empty($dpmoduledrop) || empty($currentaddress) || empty($rfqreference) || empty($pressureangle) || empty($helixangle) || empty($helixhand) || empty($pitchtext) || empty($pitchdrop) || empty($gauge) || empty($typefit) || empty($facetext) || empty($facedrop) || empty($quantity) || empty($materials) ||empty($notes) */) { header( "Location: $errorurl" ); exit ; } $contactname = strtok( $contactname, "\r\n" ); $email = strtok( $email, "\r\n" ); if (get_magic_quotes_gpc()) { $chkno = stripslashes( $chkno ); $companyname = stripslashes( $companyname ); $currentaddress = stripslashes( $currentaddress ); $contactnumber = stripslashes( $contactnumber ); $rfqreference = stripslashes( $rfqreference ); $teeth = stripslashes( $teeth ); $dpmoduletext = stripslashes( $dpmoduletext ); $dpmoduledrop = stripslashes( $dpmoduledrop ); $pressureangle = stripslashes( $pressureangle ); $helixangle = stripslashes( $helixangle ); $helixhand = stripslashes( $helixhand ); $pitchtext = stripslashes( $pitchtext ); $pitchdrop = stripslashes( $pitchdrop ); $gauge = stripslashes( $gauge ); $typefit = stripslashes( $typefit ); $facetext = stripslashes( $facetext ); $facedrop = stripslashes( $facedrop ); $quantity = stripslashes( $quantity ); $materials = stripslashes( $materials ); $notes = stripslashes( $notes ); } ini_set("sendmail_from", $from); mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" ); exit ; ?>
  6. Hi Rhodesa, You were right, it was my web hosts, thankyou for helping me with this.
  7. Yeah I tried it, again, it works fine on my server, not on the clients. I get the thankyou message up but I never recieve the email.
  8. I just tried it on my server with the echo $email; command and it didnt come up with anything. As you can see I am a beginner. I would love to get into PHP more though
  9. I put the echo where you said but it didnt show up on screen, I put a print there as well and that didnt. Is it because it goes to the 'thankyou' or 'error' pages before it has chance to show? print ("Hello World! <br />"); echo ("Hello World! <br />"); Just for testing purposes, I just used the exact same script on my own server and it was fine! And the two hello worlds showed up!
  10. Thank you for that although it still doesnt seem to be working. It is a windows server, I have added an infofile for you to have a look at, to see if there is anything on there. Thank you for helping http://www.splinegauges.co.uk/phpinfo.php
  11. Hi, can anybody please help me. I am looking to change my code to accommodate this email reply. Is it reletively straight forward to do this? Thank you The email that I recieved from the hosts was... The smtp server to use is smtp.danahermail.com. We are not allowed to send out email on our own. It must go to smtp.danahermail.com then it will go out from there 1. 2. <?php 3. 4. error_reporting(E_ALL); 5. ini_set("display_errors", 1); 6. 7. // ------------- CONFIGURABLE SECTION ------------------------ 8. 9. $to = 'whoever@whoever.com' ;// $subject - set to the Subject line of the email, eg 10. //$subject = "Feedback Form" ; 11. 12. $subject = "Plug Gauge Quote Request Form" ; 13. 14. $formurl = "/pluggauge.htm"; 15. $errorurl = "/enquiryform/error.htm" ; 16. $thankyouurl = "/enquiryform/thankyou.htm" ; 17. 18. 19. // -------------------- END OF CONFIGURABLE SECTION --------------- 20. 21. 22. $contactname = $_POST['contactname'] ; 23. $companyname = $_POST['companyname'] ; 24. $currentaddress = $_POST['currentaddress'] ; 25. $contactnumber = $_POST['contactnumber'] ; 26. $rfqreference = $_POST['rfqreference'] ; 27. $teeth = $_POST['teeth'] ; 28. $dpmoduletext = $_POST['dpmoduletext'] ; 29. $dpmoduledrop = $_POST['dpmoduledrop'] ; 30. $pressureangle = $_POST['pressureangle'] ; 31. $helixangle = $_POST['helixangle'] ; 32. $helixhand = $_POST['helixhand'] ; 33. $pitchtext = $_POST['pitchtext'] ; 34. $pitchdrop = $_POST['pitchdrop'] ; 35. $gauge = $_POST['gauge'] ; 36. $typefit = $_POST['typefit'] ; 37. $facetext = $_POST['facetext'] ; 38. $facedrop = $_POST['facedrop'] ; 39. $quantity = $_POST['quantity'] ; 40. $materials = $_POST['materials'] ; 41. $notes = $_POST['notes'] ; 42. 43. 44. $chknotest = $_POST['chkno'] ; 45. 46. 47. // Read POST request params into global vars 48. 49. $from = $_POST['from']; 50. 51. // Obtain file upload vars 52. $fileatt = $_FILES['fileatt']['tmp_name']; 53. $fileatt_type = $_FILES['fileatt']['type']; 54. $fileatt_name = $_FILES['fileatt']['name']; 55. 56. $headers = "From: $from"; 57. 58. $file = fopen($filesize, 'rb'); 59. if (filesize($fileatt)==0){} 60. else{$page_content = fread($file, filesize($fileatt));} 61. 62. // Generate a boundary string 63. $semi_rand = md5(time()); 64. $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 65. 66. $message .= 67. 68. "\n\n-- Chk --\n\n" . 69. 70. $_POST['chkno'][0] . 71. $_POST['chkno'][1] . 72. $_POST['chkno'][2] ; 73. 74. if (!empty($contactname)) { 75. $message .= "\n\n-- Contact Name --\n\n" . $contactname; 76. } 77. 78. if (!empty($companyname)) { 79. $message .= "\n\n-- Company Name --\n\n" . $companyname; 80. } 81. 82. if (!empty($currentaddress)) { 83. $message .= "\n\n-- Current Address --\n\n" . $currentaddress; 84. } 85. 86. if (!empty($contactnumber)) { 87. $message .= "\n\n-- Contact Number --\n\n" . $contactnumber; 88. } 89. 90. if (!empty($rfqreference)) { 91. $message .= "\n\n-- RFQ Reference Number --\n\n" . $rfqreference; 92. } 93. 94. if (!empty($teeth)) { 95. $message .= "\n\n-- Teeth --\n\n" . $teeth; 96. } 97. 98. if (!empty($dpmoduletext)) { 99. $message .= "\n\n-- DP Module Text --\n\n" . $dpmoduletext; 100. } 101. 102. if (!empty($dpmoduledrop)) { 103. $message .= "\n\n-- DP Module Drop --\n\n" . $dpmoduledrop; 104. } 105. 106. if (!empty($pressureangle)) { 107. $message .= "\n\n-- Pressure Angle --\n\n" . $pressureangle; 108. } 109. 110. if (!empty($helixangle)) { 111. $message .= "\n\n-- Helix Angle --\n\n" . $helixangle; 112. } 113. 114. if (!empty($helixhand)) { 115. $message .= "\n\n-- Helix Hand --\n\n" . $helixhand; 116. } 117. 118. if (!empty($pitchtext)) { 119. $message .= "\n\n-- Pitch Text (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchtext; 120. } 121. 122. if (!empty($pitchdrop)) { 123. $message .= "\n\n-- Pitch Drop (Check If Serration) --\n\n" . $dpmoduledrop . " " . $pitchdrop; 124. } 125. 126. if (!empty($gauge)) { 127. $message .= "\n\n-- Gauge Ref/Tool No. --\n\n" . $gauge; 128. } 129. 130. if (!empty($typefit)) { 131. $message .= "\n\n-- Type Fit --\n\n" . $typefit; 132. } 133. 134. if (!empty($facetext)) { 135. $message .= "\n\n-- Face Width Text --\n\n" . $facetext; 136. } 137. 138. if (!empty($facedrop)) { 139. $message .= "\n\n-- Face Width Drop --\n\n" . $facedrop; 140. } 141. 142. if (!empty($quantity)) { 143. $message .= "\n\n-- Quantity --\n\n" . $quantity; 144. } 145. 146. if (!empty($materials)) { 147. $message .= "\n\n-- Materials --\n\n" . $materials; 148. } 149. 150. if (!empty($notes)) { 151. $message .= "\n\n-- Notes --\n\n" . $notes; 152. } 153. 154. 155. // Add the headers for a file attachment 156. $headers .= "\nMIME-Version: 1.0\n" . 157. "Content-Type: multipart/mixed;\n" . 158. " boundary=\"{$mime_boundary}\""; 159. 160. // Add a multipart boundary above the plain message 161. $message = "This is a multi-part message in MIME format.\n\n" . 162. "--{$mime_boundary}\n" . 163. "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 164. "Content-Transfer-Encoding: 7bit\n\n" . 165. $message . "\n\n"; 166. 167. // Base64 encode the file data 168. $data = chunk_split(base64_encode($data)); 169. 170. // Add file attachment to the message 171. $message .= "--{$mime_boundary}\n" . 172. "Content-Type: {$fileatt_type};\n" . 173. " name=\"{$fileatt_name}\"\n" . 174. //"Content-Disposition: attachment;\n" . 175. //" filename=\"{$fileatt_name}\"\n" . 176. "Content-Transfer-Encoding: base64\n\n" . 177. $data . "\n\n" . 178. "--{$mime_boundary}--\n"; 179. 180. 181. $http_referrer = getenv( "HTTP_REFERER" ); 182. 183. if (!isset($_POST['from'])) { 184. header( "Location: $formurl" ); 185. exit ; 186. } 187. 188. if (empty($contactname) || empty($from) || empty($companyname) || empty($contactnumber) || empty($teeth) || empty($quantity) || empty($chknotest)/* || empty($dpmoduletext) || empty($dpmoduledrop) || empty($currentaddress) || empty($rfqreference) || empty($pressureangle) || empty($helixangle) || empty($helixhand) || empty($pitchtext) || empty($pitchdrop) || empty($gauge) || empty($typefit) || empty($facetext) || empty($facedrop) || empty($quantity) || empty($materials) ||empty($notes) */) { 189. header( "Location: $errorurl" ); 190. exit ; 191. } 192. 193. 194. $contactname = strtok( $contactname, "\r\n" ); 195. $email = strtok( $email, "\r\n" ); 196. if (get_magic_quotes_gpc()) { 197. 198. $chkno = stripslashes( $chkno ); 199. 200. $companyname = stripslashes( $companyname ); 201. $currentaddress = stripslashes( $currentaddress ); 202. $contactnumber = stripslashes( $contactnumber ); 203. $rfqreference = stripslashes( $rfqreference ); 204. $teeth = stripslashes( $teeth ); 205. $dpmoduletext = stripslashes( $dpmoduletext ); 206. $dpmoduledrop = stripslashes( $dpmoduledrop ); 207. $pressureangle = stripslashes( $pressureangle ); 208. $helixangle = stripslashes( $helixangle ); 209. $helixhand = stripslashes( $helixhand ); 210. $pitchtext = stripslashes( $pitchtext ); 211. $pitchdrop = stripslashes( $pitchdrop ); 212. $gauge = stripslashes( $gauge ); 213. $typefit = stripslashes( $typefit ); 214. $facetext = stripslashes( $facetext ); 215. $facedrop = stripslashes( $facedrop ); 216. $quantity = stripslashes( $quantity ); 217. $materials = stripslashes( $materials ); 218. $notes = stripslashes( $notes ); 219. } 220. 221. 222. ini_set("sendmail_from", $email); 223. 224. mail($to, $subject, $message, $headers); 225. header( "Location: $thankyouurl" ); 226. exit ; 227. 228. ?>
  12. I have done it! Not sure how, dont even know what I have done differently. The code looks exactly the same and It isn't a refresh problem. I think that I just had some of the code ordered differently! It may have been a bug but not sure, very odd but thank you all for your help.
  13. I know that there is something wrong as without the if statement, the page processes correctly and returns the 'thankyouurl' page. When I put the if statement in, the php page tries to load up and therefore is just a blank page. Very confused! @mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" );
  14. No I know, the following works fine on its own, it is part of an email that automatically sends $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2]; It is when I try adding this statement. Can I have a statement on the fly like this? Cheers... if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; };
  15. Can anyone please tell me what I am doing wrong? The syntax is wrong somewhere as the screen goes blank when processed. $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; };
  16. The proper return... Array ( [0] => [1] => [2] => ) not empty
  17. Thankyou, The return that I get is... Array ( [0] => [1] => [2] => ) not empty ... so even though there is nothing typed in the tick boxes, my test still returns not empty! My test is to determine that at least one of the tick boxes is pressed. It doesnt matter which one of the three. As I say, I am only a beginner so I am probably way off the mark, Thankyou for your help so far!
  18. Hello, I am very new to PHP so appologies if the code is awful. I am sure that someone will give me a simple answer! I have also used a few lines to test for myself. I have an HTML form that passes the variable chkno[] through to the seperate PHP file. Chkno[] is an array of 3 checkbox buttons. <input type="checkbox" id="chkno" name="chkno[]" value="(Go)"/> <input type="checkbox" id="chkno" name="chkno[]" value="(No GO Sector)"/> <input type="checkbox" id="chkno" name="chkno[]" value="(No GO Full Form)"/> When I do not click any of the buttons, my little test at the bottom returns not empty!? Please can anyone help? $chknotest0 = $_POST['chkno'][0]; $chknotest1 = $_POST['chkno'][1]; $chknotest2 = $_POST['chkno'][2]; $chknotest=array("$chknotest0", "$chknotest1", "$chknotest2"); print_r($chknotest); if (empty($chknotest)) print_r($chknotest); else echo "not empty";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.