Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/08/2014, 14:04
mortisdj
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 10 años
Puntos: 0
Respuesta: Validacion recaptcha

Código PHP:
                     <br><br>Centro: <br>
                
                     <select name="intCentro" id="intCentro" class="seleccion">
                       <?php
do {  
?>
                       <option value="<?php echo  $row_DatosCentros['intCentro']?>"><?php echo   $row_DatosCentros['provincia']." - "$row_DatosCentros['strLocalidad']." - ".$row_DatosCentros['strNombre']?></option>
                       <?php
} while ($row_DatosCentros mysql_fetch_assoc($DatosCentros));
  
$rows mysql_num_rows($DatosCentros);
  if(
$rows 0) {
      
mysql_data_seek($DatosCentros0);
      
$row_DatosCentros mysql_fetch_assoc($DatosCentros);
  }
?>
                     </select>
                     <div id="errorregistrocentro" class="ocultar texto-error">* Campo obligatorio</div>
                  
              
                      <br><br>Email:<br><input class="seleccion" id="emailregistro" name="strEmail" type="text" placeholder="E-mail*:"/>
                    <div id="errorregistroemail" class="ocultar texto-error">* Debe ser un Email válido</div>
                    <div id="errorregistroemailduplicado" class="ocultar texto-error">* Esta dirección de correo ya está siendo usada por un usuario</div>
                   
             
                      <br><br>Teléfono: <br> <input class="seleccion" id="telefonoregistro" name="intTelefono" type="text" placeholder="Teléfono*:" onClick="javascript:  borrartelefono();" />
                    <div id="errorregistrotelefono" class="ocultar texto-error">* Debe ser un Teléfono válido</div>
               
                        <br><br>Mensaje:<br><textarea class="seleccionarea" id="mensajeregistro" name="strMensaje" placeholder="Mensaje:" rows="5" onClick="javascript:  borrarmensaje();"></textarea>
<div id="errorregistromensaje" class="ocultar texto-error">* Debe escribir un Mensaje</div>
<br><br>
</tr><tr>
<td>¿Es usted un humano?</td><td>
<?php

@require_once('recaptchalib.php');
// aquí se ponen las keys solicitadas
$publickey "6LcaDPkSAAAAAMoSV_IHMJOOrYsz5I0pkC1X59Aa";
$privatekey "6LcaDPkSAAAAAMY5uEnJvZLXm4PeqGng9hpRMasq";
$resp null$error null
if (
$_POST["submit"]) { 
$resp recaptcha_check_answer ($privatekey$_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); 

if (
$resp->is_valid) { 
$to="usted@sudominio"
$subject="Titulo de ejemplo";
$body=" Mensaje formulario: Nombre: " .$_POST["nombre"] . "\n Email: " .$_POST["email"] . "\n Mensaje: " .$_POST["mensaje"] . "\n"
/* enviando correo */ 
mail($to,$subject,$body); 
echo 
"Correo Enviado!"
exit(
1); 
} else { 
echo 
"Lo sentimos pero no ha colocado el texto correctamente! Intente nuevamente..."; } 


echo 
recaptcha_get_html($publickey$error); ?>   
                    
                    
                        <div class="clear"></div>
                        <div class="btns">
                            
                           <input id="botonalta" class="botton" type="submit" value="Aceptar" onClick="javascript: return validar();"><br>
<br>
<br>

                                           
                          
                        </div>
      

                    <input type="hidden" name="MM_insert" value="formulario">
                </form>
            </div>
        </div>
    </div>
  </div>
  <!--===================footer=====================-->
  <?php include("includes/footer.php"); ?>
</section>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result
($DatosCentros);
?>
<script type="text/javascript">    
    function validar(){        
        validado = true;        
        valor = document.getElementById("nombreregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistronombre').show(1000);
              validado = false;
        } else {
            $('#errorregistronombre').hide(1000);            
        }
        
        valor = document.getElementById("apellidosregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistroapellidos').show(1000);
              validado = false;
        } else {
            $('#errorregistroapellidos').hide(1000);            
        }    
        
        valor = document.getElementById("especialidadregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
    
            $('#errorregistroespecialidad').show(1000);
              validado = false;
        } else {
            $('#errorregistroespecialidad').hide(1000);            
        }
            
/*        valor = document.getElementById("centroregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistrocentro').show(1000);
              validado = false;
        } else {
            $('#errorregistrocentro').hide(1000);            
        }
        valor = document.getElementById("localidadcentroregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistrolocalidadcentro').show(1000);
            $('#errorregistroemailduplicado').hide(1000);    
              validado = false;
        } else {
            $('#errorregistrolocalidadcentro').hide(1000);            
        }    */

        valor = document.getElementById("emailregistro").value;
        if( !(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(valor)) ) {
            $('#errorregistroemail').show(1000);
            validado = false;
        } else {
            $('#errorregistroemail').hide(1000);    
            <!---->
            <!---->
            <!---->
            <!---->
            valor = document.getElementById("emailregistro").value;
            $.ajax({
                            async: false,
                            type: "POST",
                            url:"includes/funciones-ajax.php",
                            data: 'stremailusuario='+valor+'&formid=1',
                            success: function(resp)
                            { 
                                    // El email de usuario no existe            
                                    if (resp==1){                                                    
                                                $('#errorregistroemailduplicado').hide(1000);                                                
                                        }
                                    // El email de usuario ya está en uso
                                    if (resp==0){

                                                $('#errorregistroemail').hide(1000);
                                                $('#errorregistroemailduplicado').show(1000);
                                                validado = false;
                                        }
                            }
        });
            
            
            
            <!---->
            <!---->
            <!---->
        }        
        
        valor = document.getElementById("telefonoregistro").value;
        if( !(/^\d{9}$/.test(valor)) ) {
            $('#errorregistrotelefono').show(1000);
            validado = false;            
        } else {
            $('#errorregistrotelefono').hide(1000);
            
            }
            
        valor = document.getElementById("mensajeregistro").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistromensaje').show(1000);
              validado = false;
        } else {
            $('#errorregistromensaje').hide(1000);            
        }    
    
    if (validado==false){return false;}            
    

    
    }
    </script>
    <script type="text/javascript">
    function limpiarformulario(){
    $('#errorregistronombre').hide(0);    
    document.formulario.nombreregistro.value="";
/*    $('#nombreregistro').attr('placeholder','Nombre*:');*/
    
    $('#errorregistroapellidos').hide(0);    
    document.formulario.apellidosregistro.value="";
/*    $('#apellidosregistro').attr('placeholder','Apellidos*:');*/
    
    $('#errorregistroespecialidad').hide(0);        
    document.formulario.especialidadregistro.value="";
/*    $('#especialidadregistro').attr('placeholder','Especialidad*:');*/
    
    $('#errorregistrocentro').hide(0);    
    document.formulario.centroregistro.value="";
/*    $('#centroregistro').attr('placeholder','Centro*:');*/
    
/*    $('#errorregistrolocalidadcentro').hide(0);    
    document.formulario.localidadcentroregistro.value="";
/*    $('#localidadcentroregistro').attr('placeholder','Localidad del Centro*:');*/*/
    
    $('#errorregistroemail').hide(0);
    $('#errorregistroemailduplicado').hide(0);        
    document.formulario.emailregistro.value="";
/*    $('#emailregistro').attr('placeholder','E-mail*:');*/

    $('#errorregistrotelefono').hide(0);
    document.formulario.telefonoregistro.value="";
/*    $('#telefonoregistro').attr('placeholder','Teléfono:');    */
    
    $('#errorregistromensaje').hide(0);    
    document.formulario.mensajeregistro.value="";
/*    $('#mensajeregistro').attr('placeholder','Mensaje:');    */
        }
    </script>
    

<script type="text/javascript">
function borrarnombre(){
    $('#errorregistronombre').hide(1000);
    }
function borrarapellidos(){
    $('#errorregistroapellidos').hide(1000);
    }
function borrarespecialidad(){
    $('#errorregistroespecialidad').hide(1000);
    }        
/*function borrarcentro(){
    $('#errorregistrocentro').hide(1000);
    }
function borrarlocalidadcentro(){
    $('#errorregistrolocalidadcentro').hide(1000);
    }*/
function borrartelefono(){
    $('#errorregistrotelefono').hide(1000);
    }    
function borrarmensaje(){    
    $('#errorregistromensaje').hide(1000);
    }
</script>
<script type="text/javascript">
/****************************************/
/* Validacion Acceso                    */
/*****************************************/
function validaracceso(){
    validado = true;
    valor = document.getElementById("passwordacceso").value;
    if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorpasswordacceso').show(1000);
              validado = false;
        }
    valor = document.getElementById("emailacceso").value;
    if( !(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(valor)) ) {
            $('#erroremailacceso').show(1000);
            validado = false;
        } 
    
if (validado == false) { return false;}    
}
function borrarpasswordacceso(){
    $('#errorpasswordacceso').hide(1000);
    }
function borraremailacceso(){
    $('#erroremailacceso').hide(1000);
    }
</script>