Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/11/2016, 14:37
drummerick7
 
Fecha de Ingreso: marzo-2013
Mensajes: 72
Antigüedad: 11 años, 10 meses
Puntos: 0
no inserta a base de datos

pues tengo un super probema, resulta que tengo un formulario donde primero valida y luego quiero que inserte en bd pero no inserta datos

en formulario tengo
Código HTML:
Ver original
  1. <form id="testform" novalidate>
  2.                   <div class="col-md-6 margin-15">
  3.                  
  4.                     <div class="form-group">
  5.                       <input type="hidden" id="idvivo_taller_fecha" class="form-control input-lg" placeholder="" value="<?php echo $id_fecha_taller; ?>">
  6.                     </div>
  7.                    
  8.                     <div class="form-group">
  9.                       <input type="hidden" id="idvivo_talleres" class="form-control input-lg" placeholder="" value="<?php echo $taller; ?>">
  10.                   </div>
  11.                    
  12.                     <div class="form-group">
  13.                       <input type="hidden" id="numRegis_taller" class="form-control input-lg" value="<?php echo generarCodigo(6); ?>">
  14.                     </div>
  15.                    
  16.                     <div class="form-group">
  17.                       <input type="text" id="nombreCompleto" class="form-control input-lg" placeholder="Nombre*" required data-error-msg="Necesitamos saber quien eres">
  18.                     </div>
  19.                    
  20.                     <div class="form-group">
  21.                       <input type="email" id="correo" class="form-control input-lg" placeholder="Correo*" required data-error-msg="Necesitamos saber cual es tu correo">
  22.                     </div>
  23.                    
  24.                     <div class="form-group">
  25.                       <input type="text" id="telefono" class="form-control input-lg" placeholder="Teléfono" required data-error-msg="Necesitamos saber tu número teléfonico">
  26.                     </div>
  27.                    
  28.                     <div class="form-group">
  29.                       <input type="date" id="fNacimiento" class="form-control input-lg" placeholder="Fecha de Nacimiento (DD/MM/AAAA)">
  30.                     </div>
  31.                    
  32.                     <div class="form-group">
  33.                       <input type="text" id="edad" class="form-control input-lg" placeholder="Edad">
  34.                     </div>            
  35.                   </div>
  36.                  
  37.                   <div class="col-md-6">
  38.                  
  39.                     <div class="form-group">
  40.                       <input type="text" id="ocupacion" class="form-control input-lg" placeholder="Ocupación">
  41.                     </div>
  42.                    
  43.                     <div class="form-group">
  44.                       <input type="text" id="asisteaCDDM" class="form-control input-lg" placeholder="Asiste a Comunidad de Dios Morelia">
  45.                     </div>
  46.                    
  47.                     <div class="form-group">
  48.                       <textarea cols="6" rows="7" id="coment" class="form-control input-lg" placeholder="Comentarios"></textarea>
  49.                     </div>
  50.                    
  51.                    </div>
  52.                    
  53.                     <div class="form-group">
  54.                       <input type="hidden" id="pagado" class="form-control input-lg"  value="0">
  55.                     </div> <!--pagado-->
  56.                     <div class="form-group">
  57.                       <input type="hidden" id="asistioTaller" class="form-control input-lg"  value="0">
  58.                     </div> <!--asistio-->
  59.                    
  60.                                  
  61.                                                        
  62.                     <button type="submit">Registrarme</button>
  63.                     <input type="reset" id="resetBtn" />
  64.                 </form>

en la misa pagina en script tengo (validacion)
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.       $(document).ready(function(){
  3.         $('#testform').attrvalidate();
  4.         $('#resetBtn').click(function(){ $('#testform').attrvalidate('reset'); });
  5.  
  6.         $('#expandBtn').click(function(){
  7.           var collapsible = $('#' + $(this).attr('aria-controls'));
  8.           $(collapsible).attr('aria-hidden', ($(collapsible).attr('aria-hidden') === 'false'));
  9.           $(this).attr('aria-expanded', ($(this).attr('aria-expanded') === 'false'));
  10.         });
  11.       });
  12.     </script>

en script para obtener datos: este lo mando a llamar con: <script src="vivo_script_upload.js"></script>
Código Javascript:
Ver original
  1. $(document).ready(function () {
  2.         formSubmit()
  3.         })
  4.     function formSubmit() {
  5.      
  6.       $("#testform").submit(function(e){
  7.           e.preventDefault()
  8.  
  9.             var vivo_taller_fecha_idvivo_taller_fecha                       = $('#idvivo_taller_fecha').val()
  10.             var vivo_taller_fecha_vivo_talleres_idvivo_talleres             = $('#idvivo_talleres').val()
  11.             var vivo_reg_talleres_numRegis_taller                           = $('numRegis_taller').val()
  12.             var vivo_reg_talleres_nombreCompleto                            = $('nombreCompleto').val()
  13.             var vivo_reg_talleres_correo                                    = $('correo').val()
  14.             var vivo_reg_talleres_telefono                                  = $('telefono').val()
  15.             var vivo_reg_talleres_fNacimiento                               = $('fNacimiento').val()
  16.             var vivo_reg_talleres_edad                                      = $('edad').val()
  17.             var vivo_reg_talleres_ocupacion                                 = $('ocupacion').val()
  18.             var vivo_reg_talleres_asisteaCDDM                               = $('asisteaCDDM').val()
  19.             var vivo_reg_talleres_coment                                    = $('coment').val()
  20.             var vivo_reg_talleres_pagado                                    = $('pagado').val()
  21.             var vivo_reg_talleres_asistioTaller                             = $('asistioTaller').val()
  22.            
  23.             var data = 'vivo_taller_fecha_idvivo_taller_fecha='+vivo_taller_fecha_idvivo_taller_fecha+'&vivo_taller_fecha_vivo_talleres_idvivo_talleres='+vivo_taller_fecha_vivo_talleres_idvivo_talleres+'&vivo_reg_talleres_numRegis_taller='+vivo_reg_talleres_numRegis_taller+'&vivo_reg_talleres_nombreCompleto='+vivo_reg_talleres_nombreCompleto+'&vivo_reg_talleres_correo='+vivo_reg_talleres_correo+'&vivo_reg_talleres_telefono='+vivo_reg_talleres_telefono+'&vivo_reg_talleres_fNacimiento='+vivo_reg_talleres_fNacimiento+'&vivo_reg_talleres_edad='+vivo_reg_talleres_edad+'&vivo_reg_talleres_ocupacion='+vivo_reg_talleres_ocupacion+'&vivo_reg_talleres_asisteaCDDM='+vivo_reg_talleres_asisteaCDDM+'&vivo_reg_talleres_coment='+vivo_reg_talleres_coment+'&vivo_reg_talleres_pagado='+vivo_reg_talleres_pagado+'&='+vivo_reg_talleres_asistioTaller;
  24.  
  25.           //realizamos la petición ajax con la función de jquery
  26.           $.ajax({
  27.               url: 'vivo_upload_regTaller.php',
  28.               type: 'POST',
  29.               data: data,
  30.               beforeSend: function() {
  31.                 console.log('enviando datos a bd')  
  32.               },
  33.               success: function(resp) {
  34.                   console.log('resp')  
  35.               }
  36.           })
  37.       })
  38.   }

y por ultimo para insertar datos:
Código PHP:
Ver original
  1. <?php
  2.             $vivo_taller_fecha_idvivo_taller_fecha =                $_POST['vivo_taller_fecha_idvivo_taller_fecha'];
  3.             $vivo_taller_fecha_vivo_talleres_idvivo_talleres =      $_POST['vivo_taller_fecha_vivo_talleres_idvivo_talleres'];
  4.             $vivo_reg_talleres_numRegis_taller =                    $_POST['vivo_reg_talleres_numRegis_taller'];
  5.             $vivo_reg_talleres_nombreCompleto =                     $_POST['vivo_reg_talleres_nombreCompleto'];
  6.             $vivo_reg_talleres_correo =                             $_POST['vivo_reg_talleres_correo'];
  7.             $vivo_reg_talleres_telefono =                           $_POST['vivo_reg_talleres_telefono'];
  8.             $vivo_reg_talleres_fNacimiento =                        $_POST['vivo_reg_talleres_fNacimiento'];
  9.             $vivo_reg_talleres_edad =                               $_POST['vivo_reg_talleres_edad'];
  10.             $vivo_reg_talleres_ocupacion =                          $_POST['vivo_reg_talleres_ocupacion'];
  11.             $vivo_reg_talleres_asisteaCDDM =                        $_POST['vivo_reg_talleres_asisteaCDDM'];
  12.             $vivo_reg_talleres_coment =                             $_POST['vivo_reg_talleres_coment'];
  13.             $vivo_reg_talleres_pagado =                             $_POST['vivo_reg_talleres_pagado'];
  14.             $vivo_reg_talleres_asistioTaller =                      $_POST['vivo_reg_talleres_asistioTaller'];
  15.  
  16.     $db_username = 'root';
  17.     $db_password = '';
  18.     $db_name     = 'hi29_cddm';
  19.     $db_host     = 'localhost';
  20.    
  21.     $conexion_hi29 = mysql_pconnect($hostname_conexion_hi29, $username_conexion_hi29, $password_conexion_hi29) or trigger_error(mysql_error(),E_USER_ERROR);
  22.     $sql = "INSERT INTO vivo_reg_talleres (vivo_taller_fecha_idvivo_taller_fecha, vivo_taller_fecha_vivo_talleres_idvivo_talleres, vivo_reg_talleres_numRegis_taller, vivo_reg_talleres_nombreCompleto, vivo_reg_talleres_correo, vivo_reg_talleres_telefono, vivo_reg_talleres_fNacimiento, vivo_reg_talleres_edad, vivo_reg_talleres_ocupacion, vivo_reg_talleres_asisteaCDDM, vivo_reg_talleres_coment, vivo_reg_talleres_pagado, vivo_reg_talleres_asistioTaller) VALUES ('vivo_taller_fecha_idvivo_taller_fecha', 'vivo_taller_fecha_vivo_talleres_idvivo_talleres', 'vivo_reg_talleres_numRegis_taller', 'vivo_reg_talleres_nombreCompleto', 'vivo_reg_talleres_correo', 'vivo_reg_talleres_telefono', 'vivo_reg_talleres_fNacimiento', 'vivo_reg_talleres_edad', 'vivo_reg_talleres_ocupacion', 'vivo_reg_talleres_asisteaCDDM', 'vivo_reg_talleres_coment', 'vivo_reg_talleres_pagado', 'vivo_reg_talleres_asistioTaller')";
  23.  
  24. $Result1 = mysql_query($sql, $conexion_hi29) or die(mysql_error());
  25.  
  26. ?>