获取所有POST数据并发送电子邮件

编程入门 行业动态 更新时间:2024-10-10 06:15:43
本文介绍了获取所有POST数据并发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图使用PHP Mail函数发送自己一个所有post变量的电子邮件。

到目前为止我有这个...

$ message = foreach($ _POST as $ key => $ value) echoField.htmlspecialchars($ key)。is.htmlspecialchars($ value)。< br>; $ message = wordwrap($ message,70); mail('liam@site.co.uk','sghting',$ message);

只有正在提交的消息是我的最后一个帖子记录,任何人都可以看到哪里错误? p>

解决方案

foreach($ _POST as $ key => $ value) $ message。=Field.htmlspecialchars($ key)。is.htmlspecialchars($ value)。< br>; mail('liam@site.co.uk','sghting',$ message);

$ message = foreach($ _POST as $ key => $ value )不正确,这将遍历结果并存储最后一个。您要将值存储在$ message变量中,而不是回显它们。

Im trying to use PHP Mail function to send myself an email of all post variables.

So far I have this...

$message = foreach ($_POST as $key => $value) echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>"; $message = wordwrap($message, 70); mail('liam@site.co.uk', 'sghting', $message);

Only the message being submitted is my last post record, can anybody see where im going wrong?

解决方案

foreach ($_POST as $key => $value) $message .= "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>"; mail('liam@site.co.uk', 'sghting', $message);

$message = foreach ($_POST as $key => $value) is not correct, this will iterate over the results and store the last one. You want to store the values in your $message variable, not echo them.

更多推荐

获取所有POST数据并发送电子邮件

本文发布于:2023-10-12 16:14:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485238.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送电子邮件   数据   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!