Quantcast
Channel: webdevelopplus.com » PHP Tutorial
Viewing all articles
Browse latest Browse all 6

Email Protector Made in PHP and JavaScript

$
0
0

Here We Create a Email Protector Which is Spam Proof  Help Your Email Form Unknown Spam.

For Making This We Use explode() Function Which Returns an array of substrings from a target string.

The explode() string function will break a target string into an array of substrings by taking in 2 parameters. First being the delimiter. Second parameter you feed it is the target string.

In This Code We Use a JavaScript and PHP.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
function php_email_protector($phpemail)
{
$pieces = explode("@", $phpemail);
 
echo '
<script type="text/javascript">
var a = "<a href=\'mailto:";
var b = "' . $pieces[0] . '";
var c = "' . $pieces[1] .'";
var d = "\' class=\'email\'>";
var e = "</a>";
document.write(a+b+"@"+c+d+b+"@"+c+e);
</script>
<noscript>Please enable JavaScript to view emails</noscript>
';
}
?>
<?php
function php_email_protector($phpemail)
{
$pieces = explode("@", $phpemail);

echo '
<script type="text/javascript">
var a = "<a href=\'mailto:";
var b = "' . $pieces[0] . '";
var c = "' . $pieces[1] .'";
var d = "\' class=\'email\'>";
var e = "</a>";
document.write(a+b+"@"+c+d+b+"@"+c+e);
</script>
<noscript>Please enable JavaScript to view emails</noscript>
';
}
?>

Now Then Include This Code in Another File.And Then Just Write The Below Code.

Code:

1
<?php  php_email_protector(info@webdevelopplus.com)?>
<?php  php_email_protector(info@webdevelopplus.com)?>

Viewing all articles
Browse latest Browse all 6

Trending Articles