summaryrefslogtreecommitdiffstats
path: root/user_guide/helpers/captcha_helper.html
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
committerPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
commite917f9be8b05c81357c1c2c9730d5060685d644d (patch)
treeb6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /user_guide/helpers/captcha_helper.html
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'user_guide/helpers/captcha_helper.html')
-rw-r--r--user_guide/helpers/captcha_helper.html22
1 files changed, 11 insertions, 11 deletions
diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html
index c4aa65fad..d6eb0652c 100644
--- a/user_guide/helpers/captcha_helper.html
+++ b/user_guide/helpers/captcha_helper.html
@@ -87,9 +87,9 @@ CAPTCHA Helper
<p>The "word" is the word that appears in the captcha image, which if not
supplied to the function, will be a random string.</p>
-
+
<h3>Using the CAPTCHA helper</h3>
-
+
<p>Once loaded you can generate a captcha like this:</p>
<code>$vals = array(<br />
@@ -120,14 +120,14 @@ echo $cap['image'];</code>
</ul>
<h3>Adding a Database</h3>
-
+
<p>In order for the captcha function to prevent someone from submitting, you will need
to add the information returned from <kbd>create_captcha()</kbd> function to your database.
Then, when the data from the form is submitted by the user you will need to verify
that the data exists in the database and has not expired.</p>
-
+
<p>Here is a table prototype:</p>
-
+
<code>CREATE TABLE captcha (<br />
&nbsp;captcha_id bigint(13) unsigned NOT NULL auto_increment,<br />
&nbsp;captcha_time int(10) unsigned NOT NULL,<br />
@@ -135,10 +135,10 @@ echo $cap['image'];</code>
&nbsp;word varchar(20) NOT NULL,<br />
&nbsp;PRIMARY KEY `captcha_id` (`captcha_id`),<br />
&nbsp;KEY `word` (`word`)<br />
-)</code>
+);</code>
<p>Here is an example of usage with a database. On the page where the CAPTCHA will be shown you'll have something like this:</p>
-
+
<code>$this-&gt;load-&gt;helper(&#x27;captcha&#x27;);<br />
$vals = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#x27;img_path&#x27; =&gt; &#x27;./captcha/&#x27;,<br />
@@ -161,10 +161,10 @@ echo $cap[&#x27;image&#x27;];<br />
echo &#x27;&lt;input type=&quot;text&quot; name=&quot;captcha&quot; value=&quot;&quot; /&gt;&#x27;;</code>
<p>Then, on the page that accepts the submission you'll have something like this:</p>
-
+
<code>// First, delete old captchas<br />
$expiration = time()-7200; // Two hour limit<br />
-$this-&gt;db-&gt;query(&quot;DELETE FROM captcha WHERE captcha_time &lt; &quot;.$expiration); <br />
+$this-&gt;db-&gt;query(&quot;DELETE FROM captcha WHERE captcha_time &lt; &quot;.$expiration); <br />
<br />
// Then see if a captcha exists:<br />
$sql = &quot;SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date &gt; ?&quot;;<br />
@@ -176,7 +176,7 @@ if ($row-&gt;count == 0)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;You must submit the word that appears in the image&quot;;<br />
}</code>
-
+
</div>
<!-- END CONTENT -->
@@ -192,4 +192,4 @@ Previous Topic:&nbsp;&nbsp;<a href="url_helper.html">URL Helper</a>
</div>
</body>
-</html> \ No newline at end of file
+</html>