Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/11/2012, 17:32
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 8 meses
Puntos: 10
Respuesta: No me lleva a la pagina.

Gracias por responder. Me da un error que es

Código:
ReferenceError: NUM_USUARIO is not defined
[Parar en este error] 	

window.location = "menu3.php?id="+NUM_USUARIO;
Y creo que es porque no sé sacar de un php la variable NUM_USUARIO.

Este es el valida1.php:

Código PHP:
<?php
  header
("Cache-Control: no-store, no-cache, must-revalidate");
  require_once(
'Connections/conexion.php');
  
$TELEFONO = isset($_GET['TELEFONO']) ? $_GET['TELEFONO']:"";
  
$query=("SELECT TELEFONO,NUM_USUARIO FROM usuarios WHERE TELEFONO ='".$TELEFONO."'");
  
$result mysql_query($query); 
  
$rows mysql_num_rows($result); 
  if (
$rows>=0) { 
  echo 
'1'
  }else{
    echo 
'0';  
      }
?>

Y pasarla a un cod js:


Código Javascript:
Ver original
  1. function nuevoAjax() {
  2.  
  3. * * var xmlhttp=false;
  4.  
  5. * * try {
  6.  
  7. * * * * xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  8.  
  9. * * }
  10.  
  11. * * * * catch(e){
  12.  
  13. * * * * try{
  14.  
  15. * * * * * * xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  16.  
  17. * * * * }catch(E) {
  18.  
  19. * * * * * * if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  20.  
  21. * * * * * * * * xmlhttp=new XMLHttpRequest();
  22.  
  23. * * * * }
  24.  
  25. * * }
  26.  
  27. * * return xmlhttp;
  28.  
  29. }
  30.  
  31. *
  32.  
  33. function TelefonoExiste(_TELEFONO, _callback) {
  34.    
  35.     divResultado = document.getElementById('resultado');
  36.    
  37. * * var ajax=nuevoAjax();
  38.  
  39. * ajax.open("GET", "valida1.php?TELEFONO=" + encodeURIComponent(_TELEFONO), true);
  40.  
  41. * * ajax.onreadystatechange=function() {
  42.  
  43. * * * * if ((ajax.readyState==4) && (ajax.status==200)){
  44.  
  45. * * * * * * //ejecutamos _callback como si fuese una función, pasandole el parámetro
  46.  
  47. * * * * * * _callback(ajax.responseText);
  48.  
  49. * * * * }
  50.  
  51. * * }
  52.  
  53. * * ajax.send(null);
  54.  
  55. }
  56. *
  57.  
  58. function GuardaFormulario() {
  59.  
  60. * * //usemos mejor las CoLECCIONES, y variables, así ahorramos codigo y lo hace fácil de mantener
  61.  
  62. * * var _TELEFONO = document.forms['form1'].elements['TELEFONO'];
  63.  
  64. *
  65.  
  66. * * if (_TELEFONO.value.length == 0){
  67.  
  68. * * * * alert("Insertar el Teléfono");
  69.  
  70. * * * * _TELEFONO.focus();
  71.  
  72. * * * * return 0;
  73.  
  74. * * }
  75.  
  76. * *
  77.  
  78. * * //lamamos a AJAX:
  79.  
  80. TelefonoExiste(_TELEFONO.value, function(resp) {
  81.  
  82.  if (parseInt(resp) == 1) {
  83.  
  84.  
  85. var boton = confirm("¡Usuario existente!¿Desea hacer un nuevo registro?");
  86.  
  87.  
  88. if (boton){
  89.    
  90.    
  91.     window.location.href = "menu3.php?id="+NUM_USUARIO;/////Aquí es donde no sé traer esta variable/////
  92.    
  93. } else {
  94.    
  95.     window.location.href = "menu4.php";
  96.    
  97.    *}
  98.  
  99.  }
  100. if (parseInt(resp) == 0) {
  101.  
  102. * alert("¡El Cliente se ha dado de alta!");
  103.  
  104. * document.forms['form1'].submit();////Aquí mando el formulario si el teléfono no existe.
  105.    }
  106.  
  107. });
  108.  return 0;
  109. }

Gracias.