Código PHP:
<?
session_start();
$text = rand(10000,99999);
$_SESSION['vercode'] = $text;
$height = 25;
$width = 65;
$image_p = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($image_p, 255, 255, 255);
$black = imagecolorallocate($image_p, 0, 0, 0);
$font_size = 14;
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
?>
La validación que hace es la siguiente:
Código PHP:
session_start();
if ($_POST['vercode'] != $_SESSION['logymail_vercode']) {
echo '<script language=JavaScript>
alert("Incorrecta!")</script>';
} else {
echo '<script language=JavaScript>
alert("Correcta!")</script>';
};
Código HTML:
function validate_form(theForm) { if (theForm.username.value == "") { alert("El campo \"Usuario\" esta vacio :(."); theForm.username.focus(); return (false); } if (theForm.FirstName.value == "") { alert("El campo \"Appelido(s)\" esta vacio."); theForm.FirstName.focus(); return (false); } }