Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/08/2010, 11:33
colino
 
Fecha de Ingreso: agosto-2009
Mensajes: 80
Antigüedad: 14 años, 8 meses
Puntos: 0
captcha no me actualiza

Teniendo este código

<?php
function captcha($name_img){
$key = '';
$ok = false;
$len = 8;
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
for ($i = 0; $i < $len; $i++){
$pos = rand(0, strlen($chars)-1);
$key .= $chars{$pos};
}
$im = @imagecreate(100, 30) or die("error");
imagecolorallocate($im, 0, 255, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 5, 10, 5, $key, $text_color);//tamaño letra, margen left, margen top
imagepng($im,$name_img);
imagedestroy($im);

return ($key);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<table width="100%"><form method="post" action="">
<tr>
<td><?php echo captcha("captcha.png"); ?></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="31%">IMAGEN</td>
<td width="64%"><?php echo '<img src="captcha.png" width="100" height="30" />';?></td>
</tr>
<tr>
<td>CÓDIGO SEGURIDAD</td>
<td>
<input type="text" name="textfield" />
</td>

</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="button" id="button" value="Enviar" />
</td>
</tr></form>
</table>
</body>
</html>

cuando actualizo en el navegador todo funciona perfecto, pero cuando actualizo el formulario con el submit, solo me actualiza el $key pero no la imagen captcha.png. Por que pasa eso, puede ser que el archivo esté en una carpeta temporal ? y como puedo solucionarlo

Saludos