captcha.php
Código PHP:
<?php
header('Cache-Control: no-store, no-cache, must-revalidate');
header('content-type: image/png');
session_start();
$text=random_text(5);
$_SESSION['captcha']=$text;
$imagen = ImageCreateFromPNG('resources/img/trans.png');
$colorTexto = imagecolorallocate($imagen,0xE2,0x40,0x43); // color #E24043
$fuente = "resources/otf/LithosPro-Black.otf";
$tamanoFuente="15";
imagettftext($imagen,$tamanoFuente,0,10,20,$colorTexto,$fuente,$text);
imagepng($imagen);
function random_text($length)
{
mt_srand((double)microtime()*1000000);
$i=0;
$texto='';
for($i=0;$i<$length;$i++)
{
$tmp=mt_rand(0,255);
while(!ereg("^[A-Z0-9]$", chr($tmp)))
{
$tmp=mt_rand(0,255);
}
$texto.=chr($tmp);
}
return $texto;
}
?>
Código HTML:
<p><img src="/onegin/captcha.php" id="captcha" alt="captcha" style="vertical-align: middle;"/> <input type="text" name="captcha" class="campoS" /><input type="button" name="reload" id="reload" value="Recargar" class="btn" onclick="transitionCaptcha()" /></p>
Código:
pero no me recarga, se supone que esto:function transitionCaptcha() { id=document.getElementById('captcha'); id.src='/onegin/resources/img/loading2.gif'; setTimeout("reloadCaptcha()",1000); } function reloadCaptcha() { id=document.getElementById('captcha'); id.src='/onegin/captcha.php'; }
Código PHP:
header('Cache-Control: no-store, no-cache, must-revalidate');