WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Protect your mailto: email addresses from bots
Categories : PHP, Email, Java Script Click here to Update Your Picture
matthew waygood
Date : Jul 22nd 2004
Grade : 3 of 5 (graded 4 times)
Viewed : 7480
File : No file for this code example.
Images : No Images for this code example.
Search : More code by matthew waygood
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

After reading an example of how to secure your email on your website from robots, which was incorrect, as it was pure PHP, I decided to give you my function for doing it.
The code below takes 1 or 2 parameters, the email and the text for the link. If you omit the text, the email address is used.

<?php

function secure_email($email, $name=null)
{
   
$email_parts=split("@",$email);
   
$email_parts[1]=str_replace(".", ".", $email_parts[1]);

    if(
is_null($name))
    {
       
$name='\' + user + \'@\' + site + \'';
    }
    else
    {
       
// change ' to \' to prevent messing up javascript, dont addslashes as only ' needs to be converted
       
$name=str_replace("'", "\'", $name);
    }

   
$code="";
   
$code.='<script language="JavaScript">' . "\n";
   
$code.='<!-- Begin user' . "\n";
   
$code.='user = "' . $email_parts[0] . '";' . "\n";
   
$code.='site = "' . $email_parts[1] . '";' . "\n";
   
$code.='document.write(\'<a href=\\"mailto:\' + user + \'&#64;\' + site + \'\\">\');' . "\n";
   
$code.='document.write(\'' . $name . '</a>\');' . "\n";
   
$code.='// End -->' . "\n";
   
$code.='</script>' . "\n";

    return
$code;
}

echo
secure_email("bob@hotmail.com");
echo
secure_email("bob@hotmail.com", "email me");
echo
secure_email("bob@hotmail.com", "don't email me");
?>



Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
phpEasyMail: An easy way to send data from HTML-forms via EMail.
Categories : Email, HTML and PHP, Complete Programs, PHP
How to check if JavaScript is enabled on a remote browser with PHP
Categories : PHP, Java Script
validateEmail 2.0 - upgraded version of the old validateEmail function used to validate email addresses via SMTP and regex.
Categories : Email, Regexps, PHP
Broadcast HTML Email
Categories : PHP, Email, MySQL, Databases
POP3 Class
Categories : PHP Classes, PHP, Email
Validator 98 - a PHP-script to generate form-validation-code in JavaScript.
Categories : Complete Programs, Java Script, PHP, HTML and PHP
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
Classic guest book made with PHP and Flash
Categories : PHP, Flash, Java Script
email validator check checker email e-mail email address
Categories : PHP, Email, Regexps
Upload any fixed type of files, control file type through javascript and encrypt filename using php so file not get overwrite
Categories : PHP, Java Script, Functions, PHP References, Form Processing
simple script to send emails via a html-form to different users
Categories : Email, MySQL, PHP, Databases
Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item.
Categories : PHP Classes, PHP, Java Script, DHTML
Protect your email links from being spidered by spam email robots!
Categories : PHP, Security, Mail, Email
 matthew waygood wrote : 1167
Hello,
I recommend you use another persons code as it has been tested and found to work with a few email extractors I have and doesnt use javascript, so it can be used with browsers that have javascript turned off.

Protect your mailto: email addresses from bots - pure PHP
Submitted by: Klingenspor Gerd 
http://www.weberdev.com/get_example.php3/3957
 
 Sarah King wrote :1173
Here`s another option (although not favoured by this author).
http://www.weberdev.com/get_example.php3?count=3939