tutorialtastic

PHPFanBase: JavaScript Spam Protection

This tutorial will show you how to implement basic JavaScript protection to deter automated spam bots from filling in fake applications at your fanlisting.

Open join.php and find the following line (and fix the typo "Subtmit"; this should be "Submit"):
<td><input type="submit" name="Subtmit Button" value="Join!" size="30" class="button"> <input type="reset" name="Reset Button" value="Don't" size="30" class="button"></td>

..just after the reset button code, and just before the </td>, add the following:
<script type="text/javascript">
<!--
document.write('<input type="hidden" name="spamproofing" id="spamproofing" value="SPAMWORD" />');
//-->
</script>
<noscript><div>JavaScript must be enabled to join due to spam restrictions in place.</div></noscript>

Next, find:
<? } elseif (isset($_GET['action']) && $_GET['action'] == "process") {
After it, add:
if (!isset($_POST['spamproofing']) || $_POST['spamproofing'] != "SPAMWORD") {
echo "<p>JavaScript must be enabled to join here due to spam restrictions in place.</p>";
exit;
}

Swap SPAMWORD for a word of your choice — make sure both occurances are absolutely identical otherwise people won't be able to join your fanlistings!

You can test your new spam proofing by turning off JavaScript and trying to join your own fanlisting/s.

Please note: this method of spam reduction is not completely foolproof. There is no way to 100% prevent spam. This method will only work against spam bots that do not understand JavaScript.

Tags: phpfanbase, javascript, spam, script-modding,
Last Updated On: 01st July 06 by Jem
Bookmark At: StumbleUpon, Digg

tutorialtastic — ultimately better than pixelfx
Copyright © Jem Turner 2003-08. (About | Disclaimer | Link In)