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
PHP Web Logs (BLogs)
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
Submit Site
Forex Trading Online forex trading platform

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 : 6149
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");
?>



Email a user with out exposing email address
Categories : PHP, Databases, MySQL, Email
Javascript URL and Email Validation
Categories : Java Script, Data Validation, Form Processing, Email, URLs
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
Zephyr: AJAX Based Framework for PHP5 Developers
Categories : PHP, AJAX, Frameworks, Java Script, Web Applications
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
Array values from javascript to php
Categories : PHP, Java Script, Arrays
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
PHP Interaction with Javascript windows
Categories : Java Script, PHP
Builds JavaScript that updates the contents of one selector based on another.
Categories : HTML, Java Script, PHP, Complete Programs, General
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo.
Categories : Graphics, PHP, Complete Programs, Java Script
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
 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