Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/03/2012, 09:52
Avatar de Oscar_Hidro
Oscar_Hidro
 
Fecha de Ingreso: septiembre-2011
Ubicación: Aguascalientes, Mexico.
Mensajes: 200
Antigüedad: 12 años, 7 meses
Puntos: 25
Pregunta Redireccionar a otra pagina despues de llenar un formulario

Que tal foreros, como estan? Hoy vengo con un problema al cual le sigo dando vueltas y vueltas. Parece algo simple pero no he podido encontrar aun la solucion.

Tengo un formulario con una validacion todavia simple con php, en donde solamente detecto si los campos que yo considero obligatorios estan llenos, entonces procedo a hacer la captura a mi base de datos. Hasta aqui todo perdecto. El problema viene ya al momento de querer que me redireccione a otra pagina despues de que mi validacion sea hecha.

Es decir, lo que necesito es que mientras se cumpla que los campos obligatorios estan llenos, que mi validacion pase, me redireccione hasta ese momento a otra pagina. Si faltan por rellenar campos, que siga en la misma pagina del formulario.

Ojala me puedan ayudar. Les codigo de lo que estoy haciendo. Primeramente e formulario:

Código PHP:
Ver original
  1. <form method="post" action="" id="form">
  2. <input id="bf1" style="top:105px;" type="text" name="name_user" class="name_user" value="" />
  3. <input id="bf1" style="top:130px;" type="text" name="apat" class="apat" value="" />
  4. <input id="bf1" style="top:155px;" type="text" name="amat" class="amat" value="" />
  5. <input id="bf1" style="top:180px;" type="text" name="date" class="date" value="" placeholder="dd-mm-aaaa" />
  6. <input id="sx1" type="radio" name="sx" class="sx" value="Masculino" /><input id="sx2" type="radio" name="sx"  class="sx" value="Femenino"/>
  7. <input id="bf1" style="top:225px;" type="text" name="profession" class="profession" value="" />
  8. <input id="bf1" style="top:250px;" type="text" name="specialty" class="specialty" value="" />
  9. <input id="bf1" style="top:275px;" type="text" name="mail" class="mail" value="" />
  10.  
  11. <input id="bf2" style="top:103px;" type="text" name="company" class="company" />
  12. <input id="bf2" style="top:125px;" type="text" name="b_name" class="b_name" />
  13. <input id="bf2" style="top:150px;" type="text" name="post" class="post" />
  14. <input id="bf2" style="top:175px;" type="text" name="codezip" class="codezip" />
  15. <input id="bf2" style="top:200px;" type="text" name="state" class="state" />
  16. <input id="bf2" style="top:223px;" type="text" name="municipality" class="municipality" />
  17. <input id="bf2" style="top:247px;" type="text" name="street" class="street" />
  18. <input id="bf2" style="top:272px;" type="text" name="colony" class="colony" />
  19. <input id="bf2t1" style="top:295px;" type="text" name="tel" class="tel" />
  20. <input id="bf2t2" style="top:295px;" type="text" name="tel_ext" class="tel_ext" />
  21.  
  22. <div id="terminos">
  23. <input id="acept" type="radio" />Acepto, consiento y autorizo que mis datos personales serán tratados conforme a lo previsto en el presente <a href="#">aviso de privacidad.</a>
  24. <div id="inactive"></div>
  25. <input id="next" type="button" value="" >
  26.  
  27. </div>
  28.  
  29. <!-- <input id="bfr3" style="top:98px;" type="checkbox" name="fact" class="fact" /> -->
  30.  
  31. <input id="bf3" style="top:125px;" type="text" name="bname_ent" class="bname_ent" />
  32. <input id="bf3" style="top:147px;" type="text" name="rfc" class="rfc" />
  33. <input id="bf3" style="top:173px;" type="text" name="state_ent" class="state_ent" />
  34. <input id="bf3" style="top:197px;" type="text" name="mun_ent" class="mun_ent" />
  35. <input id="bf3" style="top:223px;" type="text" name="street_ent" class="street_ent" />
  36. <input id="bf3" style="top:245px;" type="text" name="colony_ent" class="colony_ent" />
  37. <input id="bf3" style="top:267px;" type="text" name="codez_ent" class="codez_ent" />
  38. <input id="bf3t1" style="top:290px;" type="text" name="tel_ent" class="tel_ent" />
  39. <input id="bf3t2" style="top:290px;" type="text" name="tel_ext_ent" class="tel_ext_ent" />
  40.  
  41.  
  42. <input type="submit" id="send" value="" />
  43. </form>

Y la validacion simple de los campos obligatorios:

Código PHP:
Ver original
  1. <?php
  2. $name=strip_tags($_POST['name_user']);
  3. $name=htmlentities($_POST['name_user']);
  4. $apat=strip_tags($_POST['apat']);
  5. $apat=htmlentities($_POST['apat']);
  6. $amat=strip_tags($_POST['amat']);
  7. $amat=htmlentities($_POST['amat']);
  8. $date=strip_tags($_POST['date']);
  9. $date=htmlentities($_POST['date']);
  10. $sx=strip_tags($_POST['sx']);
  11. $sx=htmlentities($_POST['sx']);
  12. $profession=strip_tags($_POST['profession']);
  13. $profession=htmlentities($_POST['profession']);
  14. $special=strip_tags($_POST['specialty']);
  15. $special=htmlentities($_POST['specialty']);
  16. $mail=strip_tags($_POST['mail']);
  17. $mail=htmlentities($_POST['mail']);
  18. $company=strip_tags($_POST['company']);
  19. $company=htmlentities($_POST['company']);
  20. $bname=strip_tags($_POST['b_name']);
  21. $bname=htmlentities($_POST['b_name']);
  22. $post=strip_tags($_POST['post']);
  23. $post=htmlentities($_POST['post']);
  24. $codez=strip_tags($_POST['codezip']);
  25. $codez=htmlentities($_POST['codezip']);
  26. $state=strip_tags($_POST['state']);
  27. $state=htmlentities($_POST['state']);
  28. $mun_c=strip_tags($_POST['municipality']);
  29. $mun_c=htmlentities($_POST['municipality']);
  30. $street_c=strip_tags($_POST['street']);
  31. $street_c=htmlentities($_POST['street']);
  32. $col_c=strip_tags($_POST['colony']);
  33. $col_c=htmlentities($_POST['colony']);
  34. $tel_c=strip_tags($_POST['tel']);
  35. $tel_c=htmlentities($_POST['tel']);
  36. $ext_c=strip_tags($_POST['tel_ext']);
  37. $ext_c=htmlentities($_POST['tel_ext']);
  38. $bname_c=strip_tags($_POST['bname_ent']);
  39. $bname_c=htmlentities($_POST['bname_ent']);
  40. $rfc=strip_tags($_POST['rfc']);
  41. $rfc=htmlentities($_POST['rfc']);
  42. $state_f=strip_tags($_POST['state_ent']);
  43. $state_f=htmlentities($_POST['state_ent']);
  44. $mun_f=strip_tags($_POST['mun_ent']);
  45. $mun_f=htmlentities($_POST['mun_ent']);
  46. $street_f=strip_tags($_POST['street_ent']);
  47. $street_f=htmlentities($_POST['street_ent']);
  48. $col_f=strip_tags($_POST['colony_ent']);
  49. $col_f=htmlentities($_POST['colony_ent']);
  50. $code_f=strip_tags($_POST['codez_ent']);
  51. $code_f=htmlentities($_POST['codez_ent']);
  52. $tel_f=strip_tags($_POST['tel_ent']);
  53. $tel_f=htmlentities($_POST['tel_ent']);
  54. $ext_f=strip_tags($_POST['tel_ext_ent']);
  55. $ext_f=htmlentities($_POST['tel_ext_ent']);
  56. if(!empty($name) && !empty($apat) && !empty($amat) && !empty($date) && !empty($sx) && !empty($profession) && !empty($special) && !empty($mail)&& !empty($company)&& !empty($bname)&& !empty($post)&& !empty($codez)&& !empty($state)&& !empty($mun_c)&& !empty($street_c)&& !empty($col_c)&& !empty($tel_c) && !empty($bname_c)&& !empty($rfc)&& !empty($state_f)&& !empty($mun_f)&& !empty($street_f)&& !empty($col_f)&& !empty($code_f)&& !empty($tel_f)){
  57. $nac = date('Y-m-d', strtotime($date));
  58. $query=mysql_query("INSERT INTO user(nombre, ap_paterno, ap_materno, nacimiento, sexo, profesion, especialidad, mail) VALUES('{$name}','{$apat}','{$amat}','{$nac}','{$sx}','{$profession}','{$special}','{$mail}')", $conexion);
  59. $query2=mysql_query("INSERT INTO empresa(empresa, razon_social, puesto, codigo_postal, estado, municipio, calle_num, colonia, telefono, extension) VALUES ('{$company}','{$bname}','{$post}','{$codez}','{$state}','{$mun_c}','{$street_c}','{$col_c}','{$tel_c}','{$ext_c}')", $conexion);
  60. $query3=mysql_query("INSERT INTO facturacion(razon_social_f, rfc, estado_f, municipio_f, calle_num_f, colonia_f, codigo_postal_f, telefono_f, extension_f) VALUES ('{$bname_c}','{$rfc}','{$state_f}','{$mun_f}','{$street_f}','{$col_f}','{$code_f}','{$tel_f}','{$ext_f}')", $conexion);
  61. }
  62. ?>