2013-04-22 5 views
-1

나는 꽤 많은 이메일 양식 데이터를 작성하고이를 txt 파일로 보내는 스크립트가 있습니다. 내 질문은 텍스트 파일로 보내지 메시지의 일부를 어떻게 제외합니까? 텍스트 파일에 다음 줄을 보내지 않으려합니다.메시지의 일부를 txt 파일로 보내지 못하도록합니다.

$message .= "A quote will be forwarded to 
Joe Greeninger before order is placed.\n"; 

도와주세요! 방법?

<?php 
//$silver_name_badges = !empty($_POST['silver_name_badges']) ? ($_POST['silver_name_badges'])) : false; 
$SilverNameBadges = $_POST['Silver_Name_Badges']; 
$CoffeeMug = $_POST['Coffee_Mug']; 
$Plastic_Literature_Bag = $_POST['Plastic_Literature_Bag']; 
$Amada_Bag = $_POST['Amada_bag']; 
$Candy = $_POST['Candy']; 
$Moist_Towlette = $_POST['Moist_Towlette']; 
$Notepad_and_Pen = $_POST['Notepad_and_Pen']; 
$Tuck_Box = $_POST['Tuck_Box']; 
$Amada_Tie = $_POST['Amada_Tie']; 
$Cap = $_POST['Cap']; 
$name = $_POST['Attention_To']; 
$Red_Lanyard = $_POST['Red_Lanyard']; 
$White_Lanyard = $_POST['White_Lanyard']; 
$Green_Lanyard = $_POST['Green_Lanyard']; 
$Black_Lanyard = $_POST['Black_Lanyard']; 
$Glass_LC2415_NT = $_POST['Glass_LC2415_NT']; 
$Glass_FOM2NTRI = $_POST['Glass_FOM2NTRI']; 
$Glass_ASTRO_165WNT = $_POST['Glass_ASTRO_165WNT']; 
$Glass_FOL_AJ3015 = $_POST['Glass_FOL_AJ3015']; 
$Glass_ACIES_NT = $_POST['Glass_ACIES_NT']; 
$Notes = $_POST['Notes']; 
$Ship_Preference = $_POST['Ship_Preference']; 



// Please specify your Mail Server - Example: mail.yourdomain.com. 
ini_set("SMTP","mail.amada-america.com"); 

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports. 
ini_set("smtp_port","25"); 

// Please specify the return address to use 
ini_set('sendmail_from', '[email protected]'); 

// Set parameters of the email 
$to = "[email protected]"; 
$subject = "Amada Promo Items Ordered"; 
$from = " [email protected]"; 
$headers = "CC: [email protected]"; 


$message = ""; 
$message .= date("m-d-Y\n"); 
$message .= "Order has been placed. 
Items:\n"; 
foreach ($_POST as $fieldName => $fieldValue){ 
    if (!empty($fieldValue)) 
     $message .= " $fieldName: $fieldValue\n"; 
} 
$message .= "A quote will be forwarded to 
Joe Greeninger before order is placed.\n"; 
$message = str_replace("_"," ",$message); 


// Mail function that sends the email. 
mail($to,$subject,$message,$footer,$headers); 

$fp = fopen("latc.txt", "a"); 
fwrite($fp, $message."\r\n"); 
fclose($fp); 
    header('Location: index.html'); 

?> 
+0

미친 질문을! 이 "문제"에서 어떻게 실패 할 수 있습니까? – hek2mgl

+0

언제든지 삭제할 수 있습니까? ;-) – bestprogrammerintheworld

답변

2

변경 일의 순서는 메시지에이 라인을 추가하기 전에 파일을 쓸 수 있도록 :

foreach ($_POST as $fieldName => $fieldValue){ 
    if (!empty($fieldValue)) 
     $message .= " $fieldName: $fieldValue\n"; 
} 
$message = str_replace("_"," ",$message); 

$fp = fopen("latc.txt", "a"); 
fwrite($fp, $message."\r\n"); 
fclose($fp); 

$message .= "A quote will be forwarded to 
Joe Greeninger before order is placed.\n"; 


// Mail function that sends the email. 
mail($to,$subject,$message,$footer,$headers); 
+0

멋진 캐치! ... – hek2mgl

+0

duh !!! 감사. 나는 멍청한 놈이야. 매우 멍청한 놈! – user2292469

+0

$ 메시지를 만드는 방법 = "주문을하기 전에 Joe Greeninger에게 으로 견적을 전달합니다. \ n"; 이메일에 빨간색으로 나옵니 까? – user2292469

0

이 시도 :

<?php 
//$silver_name_badges = !empty($_POST['silver_name_badges']) ? ($_POST['silver_name_badges'])) : false; 
$SilverNameBadges = $_POST['Silver_Name_Badges']; 
$CoffeeMug = $_POST['Coffee_Mug']; 
$Plastic_Literature_Bag = $_POST['Plastic_Literature_Bag']; 
$Amada_Bag = $_POST['Amada_bag']; 
$Candy = $_POST['Candy']; 
$Moist_Towlette = $_POST['Moist_Towlette']; 
$Notepad_and_Pen = $_POST['Notepad_and_Pen']; 
$Tuck_Box = $_POST['Tuck_Box']; 
$Amada_Tie = $_POST['Amada_Tie']; 
$Cap = $_POST['Cap']; 
$name = $_POST['Attention_To']; 
$Red_Lanyard = $_POST['Red_Lanyard']; 
$White_Lanyard = $_POST['White_Lanyard']; 
$Green_Lanyard = $_POST['Green_Lanyard']; 
$Black_Lanyard = $_POST['Black_Lanyard']; 
$Glass_LC2415_NT = $_POST['Glass_LC2415_NT']; 
$Glass_FOM2NTRI = $_POST['Glass_FOM2NTRI']; 
$Glass_ASTRO_165WNT = $_POST['Glass_ASTRO_165WNT']; 
$Glass_FOL_AJ3015 = $_POST['Glass_FOL_AJ3015']; 
$Glass_ACIES_NT = $_POST['Glass_ACIES_NT']; 
$Notes = $_POST['Notes']; 
$Ship_Preference = $_POST['Ship_Preference']; 



// Please specify your Mail Server - Example: mail.yourdomain.com. 
ini_set("SMTP","mail.amada-america.com"); 

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports. 
ini_set("smtp_port","25"); 

// Please specify the return address to use 
ini_set('sendmail_from', '[email protected]'); 

// Set parameters of the email 
$to = "[email protected]"; 
$subject = "Amada Promo Items Ordered"; 
$from = " [email protected]"; 
$headers = "CC: [email protected]"; 


$message = ""; 
$message .= date("m-d-Y\n"); 
$message .= "Order has been placed. 
Items:\n"; 
foreach ($_POST as $fieldName => $fieldValue){ 
    if (!empty($fieldValue)) 
     $message .= " $fieldName: $fieldValue\n"; 
} 

$message = str_replace("_"," ",$message); 


// Mail function that sends the email. 
$mailMsg = $message . " A quote will be forwarded to Joe Greeninger before order is placed.\n"; 
mail($to,$subject,$mailMsg,$footer,$headers); 

$fp = fopen("latc.txt", "a"); 
fwrite($fp, $message."\r\n"); 
fclose($fp); 
    header('Location: index.html'); 
?> 
관련 문제