How to hide email on a site from spammers

The first way through JavaScript:

<script type="text/javascript" language="JavaScript">
var login  = 'user';
var server = 'domain.com';
var email  = login+'@'+server;
var url = 'mailto:'+email;
document.write('<a href="'+url+'">'+email+'</a>');
</script>
 
<noscript><img src="URL_img"></noscript>

If the user has JavaScript disabled, then the picture indicated in the noscript tags will be displayed.

The second way through PHP:

<?php
$email = 'user@domain.com';
$url = 'mailto:user@domain.com';
$safe_email=$safe_url='';
for($i=0; $i $safe_email .= '&#'.ord($email{$i}).';';
}
for($i=0; $i $safe_url .= '&#'.ord($url{$i}).';';
}
print "<a href="$safe_url">$safe_email</a>";
?>

Leave a comment

Leave a Reply