Jump to content

CAPTCHA/Integration/The Anti-CAPTCHA/Stronger

From Wikibooks, open books for an open world

This version of the Anti-CAPTCHA is stronger.

Form Code

[edit | edit source]

JavaScript

[edit | edit source]
document.write("<input type=hidden name=code value="+Math.random()+" />");

This must be in your form.

Use in an HTML form:

<script type="text/javascript">
document.write("<input type=hidden name=code value="+Math.random()+" />");
</script>

Server-Side Code

[edit | edit source]

Use this:

<?php

if (!$_POST['code']) {
   // abort
}

?>

Problems with this version

[edit | edit source]

It hinders the usability, as people with JavaScript disabled (for example, for security reasons) won't be able to access your form.

See also

[edit | edit source]