views:

50

answers:

2

I'm working on a website that has many business profiles with their contact information which also include email addresses. Obviously I don't want to output the plain email addresses in the source due to spam. Could do mrsmith[at]gmail.com or obfuscate with ASCII but these solutions aren't ideal, not 100% foolproof.

The profiles do have a contact form but I also need to show the email addresses.

What I want to do is encode the emails with PHP and then decode with JS and create the anchor link dynamically. So I need an algorithm that's the same in PHP an JS if there is any...

+1  A: 

First, use SSL. Then use an AJAX request to get the Data (jQuery will help with the AJAX). Seperate it into two requests. ex for [email protected]:

One request that gives yummyfood.

Then have another request that gives mybusiness.com.

The last idea is to use recaptcha mailhide (by Google). It will secure your email addressed just fine if that is the approach you want to take.

Nitroware
I rather just do something like "Are you human? type in 'yes'" than captcha, captcha is so user unfriendly...
Temega
A: 

I've now solved this with a form asking the user to fill in a value and submit it. If value i correct, show email address. Also set an 'isHuman' session parameter so others emails will just show by default.

Temega