Zend Framework

Improve Zend_Captcha usage example

Details

  • Type: Docs:  Improvement Docs: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7.2
  • Fix Version/s: 1.8.4
  • Component/s: Zend_Captcha
  • Labels:
    None
  • Language:
    English

Description

It is not very clear from the Zend_Captcha documentation exactly how to validate submitted CAPTCHAs when using Zend_Captcha as a standalone component (i.e. without Zend_Form).

The code example on: http://framework.zend.com/manual/en/zend.captcha.operation.html shows the following:

// On subsequent request:
// Assume captcha setup as before, and $value is the submitted value:
if ($captcha->isValid($_POST['foo'], $_POST)) {
    // Validated!
}

Without delving into the source code users have no way of knowing that $_POST['foo'] should be a key/value array containing the keys id (id of the generated captcha), and input (the string the user entered into a form). The comment also references the variable $value, which is never set or used (I believe this is leftover from before the 1.7 changes made as a result of issue #ZF-3995)

It would be useful if this example was extended to be a working example that included a basic HTML form showing the markup required.

Activity

Hide
Tim Fountain added a comment -

Here's a working example based on the one currently in the docs.

Show
Tim Fountain added a comment - Here's a working example based on the one currently in the docs.
Hide
Stanislav Malyshev added a comment -

thanks, I've changes the docs

Show
Stanislav Malyshev added a comment - thanks, I've changes the docs
Hide
Kevin added a comment -

Hi!
The issue still exists, the docu was never updated

The lines 12-14 say:
echo "<form method=\"post\" action=\"\">";
echo $captcha->render($view);
echo "</form>";

But they lack the most important info:

<input type="hidden" name="foo[id]" value="<?php echo $id?>" />
<input type="text" name="foo[input]" /><br />

The full example for the form is then:

echo "<form method="post" action="">";
echo $captcha->render($view);
echo '<input type="hidden" name="foo[id]" value="'.$id.'" />';
echo '<input type="text" name="foo[input]" />';
echo "</form>";

Please update the documentation, it took me two hours yesterday to figure that out.

Show
Kevin added a comment - Hi! The issue still exists, the docu was never updated The lines 12-14 say: echo "<form method=\"post\" action=\"\">"; echo $captcha->render($view); echo "</form>"; But they lack the most important info: <input type="hidden" name="foo[id]" value="<?php echo $id?>" /> <input type="text" name="foo[input]" /><br /> The full example for the form is then: echo "<form method="post" action="">"; echo $captcha->render($view); echo '<input type="hidden" name="foo[id]" value="'.$id.'" />'; echo '<input type="text" name="foo[input]" />'; echo "</form>"; Please update the documentation, it took me two hours yesterday to figure that out.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: