How do I run PHP code when a user clicks on a link?

Viewed 260097

I want to have a page run some PHP code when a user clicks on a link, without redirecting them. Is this possible with

<a href=""></a>

or with the javascript onclick event?

10 Answers
<a href='javascript:void(0)' id='yourId'>Click Me</a>

$(document).ready(function() {       
    $("#yourId").click(function() {
       $.get("yourpage.php");
       return false;;
    });
});
Related