Services_ReCaptcha
[ class tree: Services_ReCaptcha ] [ index: Services_ReCaptcha ] [ all elements ]

Source for file example-01.php

Documentation is available at example-01.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * This file is part of the PEAR Services_ReCaptcha package.
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This source file is subject to the MIT license that is available
  11.  * through the world-wide-web at the following URI:
  12.  * http://opensource.org/licenses/mit-license.php
  13.  *
  14.  * @category  Services
  15.  * @package   Services_ReCaptcha
  16.  * @author    David Jean Louis <izi@php.net>
  17.  * @copyright 2008-2009 David Jean Louis
  18.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  19.  * @version   CVS: $Id$
  20.  * @link      http://pear.php.net/package/Services_ReCaptcha
  21.  * @link      http://recaptcha.net/apidocs/captcha/client.html
  22.  * @since     File available since release 0.1.0
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * Include the Services_ReCaptcha class
  28.  */
  29. require_once 'Services/ReCaptcha.php';
  30.  
  31. // you must get your API keys here:
  32. // http://recaptcha.net/api/getkey
  33. $publicKey  'your_public_key';
  34. $privateKey 'your_private_key';
  35.  
  36. // we instanciate our Services_ReCaptcha instance with the public key and the 
  37. // private key
  38. $recaptcha = new Services_ReCaptcha($publicKey$privateKey);
  39.  
  40. // if the form was submitted and the catpcha challenge response is ok, we 
  41. // display a message and exit
  42. if (isset($_POST['submit']&& $recaptcha->validate()) {
  43.     echo "Challenge response ok !";
  44.     exit(0);
  45. }
  46.  
  47. // we display the html form
  48. ?>
  49. <html>
  50. <head>
  51.     <title>recaptcha test</title>
  52. </head>
  53. <body>
  54.     <form method="post" action="">
  55. <?php echo $recaptcha?>
  56.         <hr/>
  57.         <input type="submit" name="submit" value="Ok"/>
  58.     </form>
  59. </body>
  60. </html>

Documentation generated on Mon, 11 Mar 2019 15:43:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.