Hola. He bajé este ejemplo de creación de imagenes automática anti-bots y tengo un problema...
Este es el código:
principal.php
Código PHP:
Ver original<?php
if ($_POST["action"] == "checkdata") {
if ($_SESSION['tmptxt'] == $_POST['tmptxt']) {
echo "Bienvenido";
} else {
echo "Intentalo nuevamente";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CAPTCHA con PHP</title>
<meta name="description" content="CAPTCHA con PHP: ejemplo para demostrar la creacion de Captcha con PHP." />
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="descdet">
<div class="bordeder">
<strong class="subder">CAPTCHA con PHP </strong><br>
Ingresar el texto mostrado en la imagen <br>
<form action="principal.php" method="post">
<img src="crear_imagen.php" width="100" height="30" vspace="3"><br>
<input name="tmptxt" type="text" size="30"><br>
<input name="btget" type="submit" class="boton" value="Verificar Codigo">
<input name="action" type="hidden" value="checkdata">
</form>
</div>
</td>
</tr>
</table>
</body>
</html>
crear_imagen.php
Código PHP:
Ver original<?php
function randomText($length) {
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<$length;$i++) {
$key .= $pattern{rand(0,35)}; }
return $key;
}
$_SESSION['tmptxt'] = randomText(8);
imagestring($captcha, 5, 16, 7, $_SESSION['tmptxt'], $colText);
header("Content-type: image/gif"); ?>
El problema está en principal.php en la línea que pone
Código PHP:
Ver originalif ($_POST["action"] == "checkdata") {
Este es el error: Notice: Undefined index: action in C:\Archivos de programa\EasyPHP-5.3.2i\www\principal.php on line 4
Dice que no hay nada... inicialmente si que no hay nada pero al pulsar el submit del formulario debería recoger el valor del input hidden....
Como se puede arreglar? Gracias!