我试图把一个简单的" +"或" - "投票表格成电子邮件通讯。
// yes button "+"
<form action="/email-opinions/" method="POST">
<input type="hidden" value="GSC" name="strainName">
<input type="hidden" value="yesLike" name="strainLike">
<input type="image" src="/images/vhc/yesLike.png" alt="I Like">
</form>
// no button "-"
<form action="/email-opinions/" method="POST">
<input type="hidden" value="GSC" name="strainName">
<input type="hidden" value="noLike" name="strainLike">
<input type="image" src="/images/vhc/noLike.png" alt="I Like">
</form>
表单由wordpress页面处理:
// form vars
$strainLike = $_POST['strainLike'];
$strainName = $_POST['strainName'];
// wordpress loop
$args = array( 'posts_per_page' => -1 );
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ) :
setup_postdata( $post );
// strain data
$currentStrain = get_post_meta( $post->ID, 'strainName', true );
if ($strainName == $currentStrain) {
// set the vote scores
// no vote
if ($strainLike == 'noLike') {
// vote data
$currentYes = get_post_meta( $post->ID, 'yesLike', true );
$currentNo = get_post_meta( $post->ID, 'noLike', true );
$newVote = $currentNo + '1';
update_post_meta($post->ID, 'noLike', $newVote);
}
// yes vote
if ($strainLike == 'yesLike') {
// vote data
$currentNo = get_post_meta( $post->ID, 'noLike', true );
$currentYes = get_post_meta( $post->ID, 'yesLike', true );
$newVote = $currentYes + '1';
update_post_meta($post->ID, 'yesLike', $newVote);
}
}
endforeach; ?>
它作为网页工作正常。表单执行其应该执行的操作,但是当通过电子邮件发送并单击表单选项时,结果是或否投票不会被处理和计数或显示回选民。任何人都知道什么是错的?
答案 0 :(得分:0)
html电子邮件中通常不允许使用表单,当然也有一些例外情况。这种功能可以使用常规链接(正如上面评论中提到的henrywright)。链接是html电子邮件的基本元素,也更容易跟踪点击次数。
将2个表单更改为2个链接,2个不同的URL或具有不同参数的相同URL。