El form es el siguiente:
Código PHP:
<?php
session_start();
if (isset($_POST['enviar'])){
if ($_SESSION['textoImage'] == $_POST['texto']) {
echo '<li>correcto';
exit;
} else {
echo '<li>incorrecto';
}
}
?>
<form method="post">
<table width="362" border="1">
<tr>
<td width="197">ingrese su nombre</td>
<td width="149"><input type="text" name="textfield" id="nombre"></td>
</tr>
<tr>
<td>ingrese su apellido</td>
<td><input type="text" name="textfield2" id="apellido"></td>
</tr>
<tr>
<td>ingrese texot de la imagen</td>
<td>
<img src='captcha.php' />
<br/>
<input type="text" name="textfield2" id="texto"> </td>
</tr>
<tr>
<td><input type="submit" name="enviar" id="enviar" value="enviar consulta"></td>
<td><input type="submit" name="button2" id="button2" value="reestablecer"></td>
</tr>
</table>
</form>
Código PHP:
<?php
session_start();
require_once 'PEAR/Text/CAPTCHA.php';
$captcha = Text_CAPTCHA::factory('Image');
$opcionesImg ['font_size'] = '24';
$opcionesImg ['font_path'] = './fuentes/';
$opcionesImg ['font_file'] = 'cour.ttf';
$opcionesImg ['text_color'] = '#660000';
$opcionesImg ['lines_color'] = '#FF9966';
$opcionesImg ['background_color'] = '#FFFFCC';
$captcha->init(200, 70, NULL, $opcionesImg);
$_SESSION['textoImagen'] = $captcha->getPhrase();
$imagen = $captcha->getCAPTCHAAsPNG();
if (PEAR::isError($imagen)) {
printf('Error: %s',
$imagen->getMessage());
exit;
}
echo $imagen;
?>
Desde ya muchisimas gracias