本文介绍了获取所有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数据并发送电子邮件
发布评论