PHP - 提交<a> with method POST?

时间:2016-07-01 05:40:54

标签: php post get

I have the following button which is actually an tag:

<a id=\"Send_Mail\" class=\"btn btn-block btn-primary btn-xs\" target=\"_blank\" href=\"./sendmail.php?crs=$crs\" method=\"POST\">Send</a>

1.The problem I have is that when the button/link is clicked, my PHP script cannot verify if (isset($_POST['Send_Mail'])) { since the POST method is not supported by links.

2.I could change it to , but then have the problem that I must submit the $crs variable along with the link which doesnt allow.

What to do? How can I check whether an tag has really been clicked?

Thanks

2 个答案:

答案 0 :(得分:0)

只需点击锚标记提交页面:

<a id=\"Send_Mail\" class=\"btn btn-block btn-primary btn-xs\" >Send</a>

Jquery的:

$("#Send_Mail").click(function() {
   $("#form_id").submit();
});

答案 1 :(得分:0)

您可以为session变量设置$crs,并可以在另一个页面中访问它。这样您就可以使用<form>的提交按钮发帖,而不必使用link.try it