Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/06/2012, 04:29
Komart
 
Fecha de Ingreso: marzo-2011
Mensajes: 30
Antigüedad: 13 años, 2 meses
Puntos: 0
Validar formulario y imprimir resultados

Como hago para después de comprobar un captcha si es incorrecto que me marque la casilla de introducción de captcha en rojo o un mensaje.

A continuación os pongo lo que tengo hecho.

FORM HTML:

<FORM action="../php/envio.php" method="post"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="90%"><TR><TD width="30%"><DIV align="right"><B>Nom:</B></DIV></TD><TD width="70%"><INPUT type="text" name="name" size="20" id="name"></TD></TR><TR><TD><DIV align="right"><B>Email:</B></DIV></TD><TD><INPUT type="text" name="email" id="email" size="20"></TD></TR><TR><TD><DIV align="right"><B>Consulta:</B></DIV></TD><TD><TEXTAREA name="comment" cols="50" wrap="virtual" id="comment" rows="4"></TEXTAREA></TD></TR><TR><TD>&nbsp;</TD><TD><img align="rigth" src="../captcha/securimage_show.php" id="captcha" /><a href="#" onclick="document.getElementById('captcha').src = '../captcha/securimage_show.php?' + Math.random(); return false"><img src="../images/refresh_97252.jpg" /></a></TD></TR><TR><TD>&nbsp;</TD><TD><input type="text" name="captchacode" /></TD></TR><TR><TD>&nbsp;</TD><TD><INPUT type="submit" name="submit" value="Enviar"><INPUT type="reset" name="reset" value="Restaura"></TD></TR></TABLE>
</FORM>

Comprovacion php:


<?php

include_once("../captcha/securimage.php");
$img = new securimage();
$valido_captcha = $img->check($_POST['captchacode']);
if ($valido_captcha){


$nombre = $_POST['name'];
$mail = $_POST['email'];

$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje = "Este mensaje fue enviado por " . $nombre . " \r\n";
$mensaje .= "Su e-mail es: " . $mail . " \r\n";
$mensaje .= "Mensaje: " . $_POST['comment'] . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());

$para = '[email protected]';
$asunto = 'Contacto desde www.dominio.com';

mail($para, $asunto, $mensaje, $header);

header('Location:' . getenv('HTTP_REFERER'));
}else{
$incorrect = 2;

}
header('Location:' . getenv('HTTP_REFERER'));

?>