Forum Moderators: coopster
I've got a plain old email link on a web page. But I now want to record how many people click on it.
To do this I'll need to point the link to a PHP script to do the hit recording. But then I still want the email link to work as normal, and open up the users default mail client.
How can I do that last bit? Is there some header() code I need to add?
Thanks
my link (444 is the Id of the page im emailing about):
<a href="mailto:cantona@domain.com" onclick="apply('444');></a>
my javascript file:
// ajax set up
function getHTTPObject()
{
if (typeof XMLHttpRequest != 'undefined')
{
return new XMLHttpRequest();
}
try
{
return new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{}
}
return false;
}function apply(id) {
var myurl = "http://www.domain.com/apply_ping.php";
http.open("GET", myurl + "?id=" + escape(id), true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}
function useHttpResponse() {
if (http.readyState == 4) {
var textout = http.responseText;
document.write.textout;
}
}
and my php file:
<?php
$id = $_GET['id'];
# add $id to db
# thats it, the end
so i just want to add a row the DB with the ID in. the email click should trigger this.
any ideas? im totally new to ajax :/