<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MaggsWeb:7 &#187; captcha</title>
	<atom:link href="http://www.maggsweb.com/tag/captcha/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maggsweb.com</link>
	<description>www.maggsweb.com</description>
	<lastBuildDate>Sat, 21 Aug 2010 20:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simple captcha</title>
		<link>http://www.maggsweb.com/php/simple-captcha/</link>
		<comments>http://www.maggsweb.com/php/simple-captcha/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 11:17:43 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[captcha]]></category>

		<guid isPermaLink="false">http://www.cmaggs.co.uk/?p=24</guid>
		<description><![CDATA[Spam! Urrrgggh! Want a &#8216;simple&#8217; way of stopping spam in form submissions? Have a go at this, written by myself and used on quite a number of sites. Its simple &#8211; and works without relying on third-party-providers. Create &#8216;image.php&#8217; with the following content. ?View Code PHP$img = imagecreate(48,25); $backcolor = imagecolorallocate($img,153,0,0); $textcolor = imagecolorallocate($img,255,255,255); imagefill($img,0,0,$backcolor); [...]]]></description>
			<content:encoded><![CDATA[<p>Spam!  Urrrgggh!  Want a &#8216;simple&#8217; way of stopping spam in form submissions?  Have a go at this, written by myself and used on quite a number of sites.  Its simple &#8211; and works without relying on third-party-providers.<br />
<span id="more-272"></span><br />
Create &#8216;image.php&#8217; with the following content.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2725"><td class="code" id="p272code5"><pre class="php" style="font-family:monospace;">$img = imagecreate(48,25);
$backcolor = imagecolorallocate($img,153,0,0);
$textcolor = imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$backcolor);
$number = $_GET['rand'];
Imagestring($img,10,5,5,$number,$textcolor);
header(&quot;Content-type: image/jpeg&quot;);
imagejpeg($img);</pre></td></tr></table></div>

<p>Just before the contact form, create the random number, and copy this to a session var&#8230;.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2726"><td class="code" id="p272code6"><pre class="php" style="font-family:monospace;">$rand = rand(999,9999);
$_SESSION['rand'] = $rand;</pre></td></tr></table></div>

<p>&#8230;then enter the above image file in an image tag, like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code7'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2727"><td class="code" id="p272code7"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;/image.php?rand=$rand;&quot; /&gt;</pre></td></tr></table></div>

<p>Then submit the form and test</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?" onclick="pageTracker._trackPageview('/outgoing/www.ericbess.com/ericblog/2008/03/03/wp-codebox/_examples?referer=');"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p272code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2728"><td class="code" id="p272code8"><pre class="php" style="font-family:monospace;">$Rand = trim($txtRand);
 if (strlen($Rand) &lt;&gt; 4) {
&nbsp;
// display error and exit
 exit();
 }
 if (!($Rand == $_SESSION['rand'])) {
 echo (&quot;Random number was incorrect.&lt;br/&gt;&lt;br/&gt;Are you a SpamBot?&lt;br/&gt;
&nbsp;
&lt;br/&gt;&lt;a href='/' onfocus='blur()'&gt;HOME&lt;/a&gt;&quot;);
 exit;
 }</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maggsweb.com/php/simple-captcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
