May 17, 2008

Php - Ajax: E-mail Protection, Clickable Image

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > Others

free web hosting

Php - Ajax: E-mail Protection, Clickable Image

truefusion
Description
Concept sparked by the following topic: Email Address Protection From Spam Bots. The idea is to have an image, when clicked on, turn into selectable text. The e-mail is encoded, and that encoding is sent to the server through AJAX to be decoded via PHP. After it is decoded, it gets sent back to be inserted into a text field which is automatically selected upon clicking the image. I have decided to keep things limited to one page for now, where the concept can be easily seen.

Code
CODE
<?php

$get = $_GET['code'];

if ($get != ""){
echo "mailto: ".base64_decode($get);
} else {

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
&lt;script>
function ajaxFunction(id, code){
var xmlHttp;
try {
// Firefox, Opera, Safari, Konqueror
xmlHttp = new XMLHttpRequest();
} catch (e){
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4){
document.location.href = xmlHttp.responseText;
}
}
xmlHttp.open("GET", "antispam_email.php?code="+code, true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<noscript>In order to select the e-mail you require JavaScript enabled.</noscript>
<span id="email_link"><a href="java script: ajaxFunction('email_link', '<?php echo base64_encode("email@domain.com"); ?>');">Click Here To E-mail Me</a></span>
</body>
</html>
<?php

}

?>


Preview

Soon to Come
  • Dynamic image generation.
  • JavaScript-only version.
Changes
Got rid of the image, and turned it into a link. Made it possible to load up the e-mail program without leaving the page.

 

 

 


Reply

shadowx
Very nice! I can see many applications here for those who want to use their email address as a point of contact. Dynamic image generation would be a great bonus as that way it could be integrated into websites with many users who need to use their email address as a point of contact, EG profile sites and the like where many email addresses will be saved by this simple idea. Would i be right in assuming this code could be modified to show a MAILTO link instead of the textbox? That culd be even more useful for webmasters who use their email but want to give the user as much ease of use as possible.

Brilliant idea and code there, i can see it helping a lot of people

Reply

truefusion
QUOTE(shadowx @ Dec 12 2007, 05:20 AM) *
Would i be right in assuming this code could be modified to show a MAILTO link instead of the textbox?

Yes, it's possible to do that, and i have thought about it, but i figured, why have the user click twice? Instead, i've been trying to figure out a way to make it load in a way as if you've already clicked on a mailto link without leaving the page, you know? But i'm not quite sure how to go about it.—made it possible.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php ajax mail protection clickable image

  1. Scrolling Images? - How to Make an Image Scroll With the Page (4)
    I'm trying to make my homepage look a little fancier and I've got a nice background image,
    but I want it to scroll with my page, like if you scroll down the image will still appear like it
    does on the top of the page. Can someone tell me how to do this? I'm using Microsoft Frontpage
    to edit it. I'm not sure what programming language this would be, probably CSS or Javascript,
    but I can edit the page script with Notepad or something to make this work. Right now the page is
    purely HTML, so whichever language this is, can somebody also give me the tags and ma...
  2. Data Structures -- Binary Tree -- Mirror Image - Binary Tree -- Mirror Image (0)
  3. Ajax - A New Technology - AJAX relies on Java Script (10)
    Recently i did one of my project using AJAX and i could experience the real advantage of this
    Language , What do you say about that ?...
  4. How Can I Make An Auto-updating Shoutbox Type Script? - I have a few ideas involving AJAX but im looking for something more.. (4)
    Hi all. Ive just started to experiment with AJAX working with PHP and MYSQL to get data and display
    it and im looking to implement it into a shoutbox similar to the one here on the forums but i have a
    question... i know how to use ajax and JS to refresh the contents of a DIV every few seconds r so
    and that essentially reloads the shoutbox content as the REFRESH button does up there ^^ on the
    shoutbox but i think it silly that it should update every few seconds even if theres no new activity
    so what im looking for is a way of letting my AJAX know when there is a new ent...
  5. Ruby On Rails, Ajax, Scriptaculous, Etc. - (2)
    Since Web 2.0 has become one of the top buzzwords nowadays, I'm curious about the new languages:
    Ruby (on Rails), AJAX and scriptaculous are several methods programmers use to make web
    applications. I'd like to build some applications, but the trouble is where to start. How easy
    is it to make a web app in the first place? Which programs/languages have a learning curve
    that's not so steep? ...



Looking for php, ajax, e, mail, protection, clickable, image

Searching Video's for php, ajax, e, mail, protection, clickable, image
advertisement



Php - Ajax: E-mail Protection, Clickable Image



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE