Armitage2k Armitage2k - 5 months ago 12
PHP Question

PHP - submit <a> with method POST?

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

Answer

Just submit page on click on anchor tag:

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

Jquery:

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