You are here: Re: In email form how do we say "must be equal to X"? « PHP Programming Language « IT news, forums, messages
Re: In email form how do we say "must be equal to X"?

Posted by juglesh on 11/14/06 05:40

My function tests your human-ness, and if youre human, thanks you for
taking the test and displays the email address. Also, if you have
proven your humanity, the next time you come to the contact page, you
will be recognized by a coookie, and given the address without the
test.

<?php
ob_start();
//required for cookies to work
// including file must start output buffer - ob_start();
function spamProofEmail(){

$explanation = "
<p>Email Address:</p>
<p>Sorry, We get too much spam. <br>
You'll have to pass a little test to make sure <br>
you're human, and not a spam-bot.<br></p>";

$emailaddress = 'Dude@ExampleDomain.com';// use StudlyCaps,

$thehumanstring = 'surfsup';
$formtext = "Please type the word <strong>$thehumanstring</strong> in
the box";
$thenclick = "Then click here to get our email address.";

$sorry = "Sorry, I guess you didnt pass the test, please try again.";
$thankyou = '<BR>Thank you.<BR>';

// +++++++++++++++++++++++++++++++++++++++++++++++++

$thehumanstring = strtolower($thehumanstring);
$postlower = strtolower($_POST['humanstring']);
$formaction = $_SERVER['REQUEST_URI'];


if ($postlower == $thehumanstring){
setcookie("spambotno", "spambotno", time()+60*60*24*100, "/");
$speHTML .= $thankyou;
}


if (($_COOKIE['spambotno'] == "spambotno") OR ($postlower ==
$thehumanstring)){
$emaillower = strtolower($emailaddress);
$speHTML .= '<BR><a
href="mailto:'.$emaillower.'">'.$emailaddress.'</a>';
return $speHTML;
}



if (($_COOKIE['spambotno'] != "spambotno") && ($postlower !=
$thehumanstring)){
$speHTML .= $explanation;}
if (isset($_POST['humanstring'])){
if ($postlower != $thehumanstring){
$speHTML .= $sorry;}}

if (($_COOKIE['spambotno'] != "spambotno") && ($postlower !=
$thehumanstring)){

$speHTML .='
<form name="the_form" action="'.$formaction.'" method="POST">
'.$formtext.' <br>
<input type="text" name="humanstring" size="30">
<br />
<input type="submit" value="'.$thenclick.'">
</form>



<script language="JavaScript"><!--
document.the_form.humanstring.focus();
//--></script>
';
}
return $speHTML;
}

?>
<html>
<head></head>
<body>
This is our contact page:
<?php echo spamProofEmail(); ?>
</body>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация