HTML电子邮件中的表单不发送数据 [英] Form in HTML Email Not Posting Data
问题描述
我有一个关于为什么我的表单没有发布数据到我的PHP脚本的问题。要取消订阅我设置的电子邮件列表,我向发送了取消订阅电子邮件的用户发送了一些发布数据的表单。
< HTML>
< body>
< div>
< p>这是一条确认消息,用于确认您是否退订了sci-eng电子邮件列表。< / p>
< p>点击下面的按钮确认您的取消订阅。< / p>
< form id =unsubform>
< div class =form-in>
< input type =hiddenid =emailkeyname =emailkeyvalue =key>
< input type =hiddenid =emailname =emailvalue =email@domain.com>
< button class =btnid =submittype =submitformaction =http://redlinks.ca/sci-eng/db/unsubscribe.phpformmethod =post>退订< /按钮>
< / div>
< / form>
< / div>
< / body>
< / html>
在表单为 POST
ed,如果 $ _ POST [email]
变量中没有数据,则会得到我设置的无数据错误。我已经尝试使用 var_dump($ _ POST)
,但只是返回 array(0){}
,那是isn 'b为我工作。
最让我困惑的是当我从电子邮件中复制确切的html,并将其粘贴到空白页面中时,当我点击在提交/取消订阅它发布的数据就好了,在我的网站上的其他地方我有完全相同的脚本,唯一不同的是形式没有/ db在它。发送的页面的行为应该如何,显示数据的propper数组而不是任何内容。这是唯一的区别。
如果它有什么区别,我使用Thunderbird for Windows 10作为我的电子邮件客户端。
任何认为他们可以提供帮助的人都会被赞赏:)
由于安全问题,表单不被支持,电子邮件。大多数电子邮件客户端会警告用户有风险,或者干脆就会禁用它,并且不会像你的情况那样工作。
启用取消订阅的最佳做法是使用链接。您可以传递任何必要的参数以取消订阅链接,例如 http:/ /www.example.com/unsubscribe.php?usermail=mail@gmail.com 。
I have this question about why my form is not posting data to my PHP script. To unsubscribe from an emailing list I've set up, I send the user that has unsubscribed an email with a form that posts some data.
<html>
<body>
<div>
<p>This is a confirmation message to confirm that you unsubscribed from the sci-eng email list.</p>
<p>Click on the button below to confirm your unsubscription.</p>
<form id="unsubform">
<div class="form-in">
<input type="hidden" id="emailkey" name="emailkey" value="key">
<input type="hidden" id="email" name="email" value="email@domain.com">
<button class="btn" id="submit" type="submit" formaction="http://redlinks.ca/sci-eng/db/unsubscribe.php" formmethod="post">Unsubscribe</button>
</div>
</form>
</div>
</body>
</html>
When on the page that the form is POST
ed to, I get the "no data" error that I have set up if there is no data in the $_POST["email"]
variable. I have tried using var_dump($_POST)
, but that just returns with array(0) { }
and that isn't working for me.
The thing that confuses me the most is when I copy the exact html from the email, and paste it into a blank page, when I click on submit/unsubscribe it posts the data just fine, and elsewhere on my site I have the exact same script, the only different being the formaction is without the /db in it. The page that one is sent to behaves how it should, showing the propper array of data instead of nothing. That's the only difference.
If it makes any difference, I use Thunderbird for Windows 10 as my email client.
Anyone who thinks they can help would be appreciated :)
Due to security issues forms are not supported and not recommended within emails. Most of email clients will warn the user of a risk or simply will disable it and it will not work, like in your case.
The best practice for enabling unsubscribing is by using a link. You can pass any requierd parameter for unsubscribing on the link, for example http://www.example.com/unsubscribe.php?usermail=mail@gmail.com.
这篇关于HTML电子邮件中的表单不发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!