Email Address Cloaking Example



Email address cloaking is a way to present email addresses while making them harder for spammers to harvest.

Create a file called "email_to_image.php" with the following code:

<?php
// Tell the browser you're sending an image
Header("Content-Type: image/png");

// Grab the email from your form.
$email = $_REQUEST['email'];

// Create a thin, wide image.
$im = ImageCreate(800, 20);

// Use black text on white background
$backgroundcolor = ImageColorAllocate($im, 255, 255, 255);
$textcolor = ImageColorAllocate($im, 0, 0, 0);

// Fill with backgroundcolor
ImageFill($im, 0, 0, $backgroundcolor);

// Write out the string
ImageString($im, 5, 5, 3, $email, $textcolor);

// output straight to browser.
ImagePNG($im);
ImageDestroy($im);
?>


Then from the just call email_to_image with the email address you want. This example is in a form within a table:

<tr>
<td><div align="right">Verification Code:</div></td>
<td><img src="email_to_image.php?email=bill.gates@microsoft.com"
align="left" alt="email" /></td>
</tr>
Terms | Privacy | SiteMap | Newsletter | Contact Me | Contents © 2003-2011 That Software Guy, Inc.
Zen Cart Project Home Page | Zen Cart Forum | Zen Cart™ is © Zen Ventures, LLC.