dry69034 2013-04-22 23:21
浏览 51
已采纳

排除部分消息被发送到txt文件[关闭]

I have a script that I wrote that pretty much emails form data and sends it to a txt file. My question is how do I exclude some of the message from being sent to the text file? I don't want to send to the text file this line :

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

please help! How?

<?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
");
$message .= "Order has been placed.  
Items:
";
foreach ($_POST as $fieldName => $fieldValue){
    if (!empty($fieldValue))
        $message .= "   $fieldName: $fieldValue
";
}
$message .= "A quote will be forwarded to 
Joe Greeninger before order is placed.
";
$message = str_replace("_"," ",$message);


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

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

?>
  • 写回答

2条回答 默认 最新

  • dqr91899 2013-04-22 23:26
    关注

    Change the order of things so you write the file before adding that line to the message:

    foreach ($_POST as $fieldName => $fieldValue){
        if (!empty($fieldValue))
            $message .= "   $fieldName: $fieldValue
    ";
    }
    $message = str_replace("_"," ",$message);
    
    $fp = fopen("latc.txt", "a");
    fwrite($fp, $message."
    ");
    fclose($fp); 
    
    $message .= "A quote will be forwarded to 
    Joe Greeninger before order is placed.
    ";
    
    
    // Mail function that sends the email.
    mail($to,$subject,$message,$footer,$headers);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算