0

我有一个已购买的上传脚本。但是,我需要为其添加更多功能,而且我的 php 知识非常基础。我需要的是通过电子邮件将包含文件位置的电子邮件发送到设定的地址。基本上是通知已经上传了一些东西。

我已经弄清楚了这些代码需要输入的部分,并且已经添加了这个完美的代码:

// Send Email Notification
       $to = "info@email.co.uk";
       $subject = "A Website User uploaded files";
       $message = "The download link goes here. ";
       $from = "registrations@email.co.uk";
       $headers = "From:" . $from;
       mail($to,$subject,$message,$headers);

脚本中的下一行代码输出我想在电子邮件消息中发送的值,如下所示:

$TMPL['message'] .= '<div class="success">Download: 
<a href="index.php?a=download&q='.$execLastRow[0].'" 
target="_blank">'.$_FILES['fileselect']['name'][$key].'</a></div>';

显然这是错误的语法,但这是我试图做的事情的要点:

// Send Email Notification
       $to = "info@email.co.uk";
       $subject = "A Website User uploaded files";
       $message = "Download: <a href="index.php?a=download&q='.$execLastRow[0].'" target="_blank">'.$_FILES['fileselect']['name'][$key].'</a>. ";
       $from = "registrations@email.co.uk";
       $headers = "From:" . $from;
       mail($to,$subject,$message,$headers);

一如既往的帮助表示赞赏!

4

4 回答 4

2

您的问题是将变量放在字符串中对吗?

  $message = 'Variable1: ' . $var1 . ', Variable2: ' . $var2 . ', Variable3: ' . $var3;
于 2013-08-22T13:59:21.923 回答
2

编辑

附加到现有字符串添加.喜欢.=

$message .= 'Download: <a href="index.php?a=download&q='.$execLastRow[0].'" target="_blank">'.$_FILES['fileselect']['name'][$key].'</a>';

@DevZer0 注意到您需要添加$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";以将内容类型设置为 HTML。

编辑前

"因为你用然后开始字符串href="

所以"href 中的第一个是关闭你的字符串。

$message = 'Download: <a href="index.php?a=download&q='.$execLastRow[0].'" target="_blank">'.$_FILES['fileselect']['name'][$key].'</a>';

您可以将上面的行与您的行进行比较并检查颜色语法。

于 2013-08-22T14:01:41.500 回答
1

改变 -

$message = "Download: <a href="index.php?a=download&q='.$execLastRow[0].'" target="_blank">'.$_FILES['fileselect']['name'][$key].'</a>. ";

$message = 'Download: <a href="index.php?a=download&q='.$execLastRow[0].'" target="_blank">'.$_FILES['fileselect']['name'][$key].'</a>.';
于 2013-08-22T14:03:38.053 回答
0

您可以像这样分配文本。

$message = <<<HTML
"Download: <a href="index.php?a=download&q={$execLastRow[0]}" target="_blank">{$_FILES['fileselect']['name'][$key]}</a>. ";
HTML;
于 2013-08-22T14:01:07.680 回答