Foros del Web » Programando para Internet » PHP »

Novato Php

Estas en el tema de Novato Php en el foro de PHP en Foros del Web. Hola..soy novato en PHP no asi en programacion....hay varios puntos que no entiendo....pero este es un problema que tengo un ratito y no resuelvo.. tengo ...
  #1 (permalink)  
Antiguo 03/03/2008, 20:10
 
Fecha de Ingreso: febrero-2008
Mensajes: 4
Antigüedad: 16 años, 2 meses
Puntos: 0
Novato Php

Hola..soy novato en PHP no asi en programacion....hay varios puntos que no entiendo....pero este es un problema que tengo un ratito y no resuelvo..

tengo un formulario en html y lo valido de primer instancia con javascript si hay algun error modifico una etiqueta <p> donde escribo el error, pero despues quiero validar el captcha en PHP.... y si no es igual el texto del captcha..poder modificar..otra eiqueta <p> pero no logro hacerlo..ma ayudan...

el codigo del formulario es el siguiente:

<body>
<script language="JavaScript" src="validaJS.js"></script>
<form id="form1" name="registro" method="post" action="ValidaPHP.php">
<table width="700" border="1" bordercolor="#FFFFFF">
<tr>
<td colspan="4"><div align="center"><img src="captcha/checakey.php" alt="Captcha" width="200" height="50" align="middle" longdesc="Captcha " /></div></td>
</tr>
<tr>
<td><div align="right" >
<p> Nick: </p>
</div></td>
<td colspan="2"><input name="Nick" type="text" value="" size="10" maxlength="10" /></td>
<td><p id="ErrorNick" STYLE="color:white"> xxx </p></td>
</tr>
<tr>
<td ><div align="right">
<pre>Captura el texto de la Imagen: </pre>
</div></td>
<td colspan="2" ><input name="code" type="text" size="10" maxlength="10" /></td>
<td ><p id="ErrorCaptcha" STYLE="color:black"> . </p></td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="51" ><input name="ValidaJS" type="button" id="ValidaJS" onClick="enviar(this.form)" value="Enviar" /></td>
<td width="211" ><input name="Restablece" type="reset" value="Restablecer" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td >&nbsp;</td>
<td colspan="2" >&nbsp;</td>
<td >&nbsp;</td>
</tr>
</table>
</form>
</body>

CODIGO QUE VALIDA EN JAVASCRIPT

function enviar(form)

{


vxerror=0;
vx=trim2(form.Nick.value);
if (vx == "") {
document.getElementById("ErrorNick").style.color ="red";
document.getElementById("ErrorNick").firstChild.da ta ="(Error)-Nick vacio";
vxerror=1;
form.Nick.focus();}
else {

document.getElementById("ErrorNick").style.color ="black";
document.getElementById("ErrorNick").firstChild.da ta =".";}


if (vxerror== 0) {form.submit()};

}

AQUI ES LO QUE QUIERO MODIFICAR..YA QUE ME CARGA ESTA PAGINA..Y LO QUE QUIERO ES MODIFICAR SOLO LA ETIQUETA "ERRORCAPTCHA DEL FORMULARIO"
ESTE ES EL ARCHIVO VALIDAPHP.PHP

<?php

session_start( ); // allows us to retrieve our key form the session


if( md5( $_POST[ 'code' ] ) != $_SESSION[ 'key' ] ) {

echo " eRROR EN LA TEXTO QUE CAPTURASTE";

} else {

echo "TODO OK...";

}

?>
  #2 (permalink)  
Antiguo 11/06/2008, 14:29
Avatar de alapaco  
Fecha de Ingreso: septiembre-2003
Ubicación: Caballito - Buenos Aires - Argentina - América del Sur - Planeta Tierra - Sistema Solar - Vía Láctea
Mensajes: 216
Antigüedad: 20 años, 8 meses
Puntos: 5
Respuesta: Novato Php

Deberias ponerle como target al form un iframe, para que la validación se haga por atras y no te recargue la página, algo así sería:

Código PHP:
<iframe height="0" id="iframeValidarCaptcha" name="iframeValidarCaptcha" src="" width="0"></iframe>
<
form id="form1" name="registro" method="post" action="ValidaPHP.php" target="iframeValidarCaptcha">
..
..
..
</
form
__________________
__________________
Álvaro Lapacó
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:37.