【问题标题】:how to email database and form values如何通过电子邮件发送数据库和表单值
【发布时间】:2012-06-10 20:39:01
【问题描述】:

我有一个使用 PHP 创建的网站,用于将表单值存储在数据库中,并有一个页面根据选择显示某些用户的值。我正在尝试将这些值从数据库发送到电子邮件地址,但我无法将主题每一行的值分开。我正在使用 PHP 内置函数发送电子邮件并将值存储在主题变量中。

我尝试使用

分别添加每个变量
$subject . "content"; 

对于每个变量,但它仍然在一行中。

我现在正在考虑制作一种时事通讯类型,但不知道如何制作或使其按我的意愿工作。因此,如果有人可以帮助我以这种方式或以其他语言发送这些值。

这是我目前的代码。

   $query= sql query
    $resultt= sql result
    $roww=mysql_fetch_assoc($resultt);

    extract($roww);

    $emmessage = "User Form Information";

    $emmessage = $emmessage . "     " . "values extracted from the database from $roww

$send = @$_POST['send'];
$subject = strip_tags(@$_POST['subject']);
$reciever= strip_tags(@$_POST['email']);
$message = $emmessage;

//  Start email processing
if ($send) 
{
//  Send the message
mail($reciever, $subject, $message, "From: $email");
$emessage="Your message has been sent";
include("forme.php");

【问题讨论】:

  • 请提供一些代码,以便我们为您提供帮助(否则您将面临被否决的风险并可能导致此问题被关闭)。
  • 用我正在使用的代码编辑它。

标签: php mysql email


【解决方案1】:

您可以使用br2nl() 功能。或者,如果您按照建议直接使用\n,则应使用nl2br() 函数,以便在HTML 页面中您将获得一个新行而不是\n

【讨论】:

    【解决方案2】:

    您可以使用\n 分隔电子邮件中的行。

    $content = "Value 1 \n Value2";
    

    【讨论】:

    • 我试过了,但消息仍然在一行上,并且我在变量中写了“\n”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多