diff options
author | Pascal Kriete <pascal.kriete@ellislab.com> | 2010-11-04 22:59:52 +0100 |
---|---|---|
committer | Pascal Kriete <pascal.kriete@ellislab.com> | 2010-11-04 22:59:52 +0100 |
commit | e917f9be8b05c81357c1c2c9730d5060685d644d (patch) | |
tree | b6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /user_guide/helpers/captcha_helper.html | |
parent | 5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff) | |
parent | e1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (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.html | 22 |
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 /> captcha_id bigint(13) unsigned NOT NULL auto_increment,<br /> captcha_time int(10) unsigned NOT NULL,<br /> @@ -135,10 +135,10 @@ echo $cap['image'];</code> word varchar(20) NOT NULL,<br /> PRIMARY KEY `captcha_id` (`captcha_id`),<br /> 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->load->helper('captcha');<br /> $vals = array(<br /> 'img_path' => './captcha/',<br /> @@ -161,10 +161,10 @@ echo $cap['image'];<br /> echo '<input type="text" name="captcha" value="" />';</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->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); <br /> +$this->db->query("DELETE FROM captcha WHERE captcha_time < ".$expiration); <br /> <br /> // Then see if a captcha exists:<br /> $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date > ?";<br /> @@ -176,7 +176,7 @@ if ($row->count == 0)<br /> {<br /> echo "You must submit the word that appears in the image";<br /> }</code> - + </div> <!-- END CONTENT --> @@ -192,4 +192,4 @@ Previous Topic: <a href="url_helper.html">URL Helper</a> </div> </body> -</html>
\ No newline at end of file +</html> |