I run a Wordpress blog & I'd like to add "Report expired post" button (href + image, not input type button hopefully). I will settle with page reloading, but I'd prefer AJAX so page doesn't reload.
On click I need 2 functions executed - send mail w/ reported post's permalink in message & rewrite "Report expired post" link to inactive Reported text. Of cource, some anti-spammy feature, like one IP can report 1 post per hour would be great, but not necessary.

I currently got this far, but I can't get permalink into my email message, whats wrong?


THIS CODE IS WITHIN LOOP, SO GET_PERMALINK() SHOULD WORK
<a href="#" onclick="callFunction();">Report expired<img src="warn_sign.png"/></a>
<script type="text/javascript">
function callFunction()
{
<?php
$message = the_permalink();
$to = "xxx@xxx.lv";
$subject = "Expired post report";
$from = "xxx@xxx.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers); ?>
}
</script>