【问题标题】:Have php form submit email and a text file让php表单提交电子邮件和文本文件
【发布时间】:2014-04-12 18:58:42
【问题描述】:

您好,我的表单最近出现了一些问题。电子邮件并不总是通过,检查过垃圾邮件文件夹,不是这样。

我想知道如何将进程附加到文本中。 这是我的表格

   if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    // if verification code was correct send the message and show this page

    $message = "Lastfour: ".$lastfour."\n".$message;
    $message = "Exchange: ".$exchange."\n".$message;
    $message = "Phone: ".$phone."\n".$message;
    $message = "bedrooms: ".$bedrooms."\n".$message;
    $message = "resortname: ".$resortname."\n".$message;
    $message = "From: ".$from."\n".$message;
    $message = "lastName: ".$lastname."\n".$message;
    $message = "Name: ".$name."\n".$message;
    mail("myeamail@mail.com", 'Online Form: '.$resortname, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
    // delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');
} else {
    // if verification code was incorrect then return to contact page and show error
    header("Location:".$_SERVER['HTTP_REFERER']."?subject=$resortname&from=$from&message=$message&wrong_code=true");
    exit;
}
?>

是否对此进行了编辑,还是我需要运行另一个进程?

谢谢

【问题讨论】:

  • 您尝试过SwiftMailer PHP 邮件库吗?通常比mail 函数好很多。
  • 嗨,谢谢,我可能需要尝试一下,我有大约 100 个特定的表格,带有 3 个自定义邮件。我需要创建一些更动态的东西来对特定类型的查询进行排序

标签: php file email text


【解决方案1】:

要写入文本文件,只需将此部分添加到您希望执行该过程的位置

$myFile = "myFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "text I want to write in the file\n";
fwrite($fh, $stringData);
fclose($fh);

【讨论】:

  • 嗨,我试过了,但它不会写入文件在这里很难回复,但我想我需要顺序和正确的代码才能插入 $fh = fopen($myFile, 'a') or die("无法打开文件"); $stringData = "$name | $lastname | $from | $resortname | $bedrooms | $phone | $exchange | $lastfour\n"; fwrite($fh, $stringData); fclose($fh);这是正确的格式吗?
猜你喜欢
  • 1970-01-01
  • 2018-11-05
  • 2013-09-16
  • 2012-01-02
  • 2013-01-28
  • 2016-01-26
  • 1970-01-01
  • 2012-01-12
  • 2012-02-18
相关资源
最近更新 更多