-1

ほとんどのデータをメールで送信し、それを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', 'jgreeninger@amada.com');

// Set parameters of the email
$to = "ravila@amada.com";
$subject = "Amada Promo Items Ordered";
$from = " jgreeninger@amada.com";
$headers = "CC: ravila@amada.com";


$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');

?>
4

2 に答える 2

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);
于 2013-04-22T23:26:00.420 に答える
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', 'jgreeninger@amada.com');

// Set parameters of the email
$to = "ravila@amada.com";
$subject = "Amada Promo Items Ordered";
$from = " jgreeninger@amada.com";
$headers = "CC: ravila@amada.com";


$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');
?>
于 2013-04-22T23:25:53.063 に答える