简体   繁体   中英

Encode email with PHP then decode with JS

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...

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 yummyfood@mybusiness.com:

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM