Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2013, 08:14
ambichol
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 3 meses
Puntos: 5
Exclamación Problemas con Login

Hola, necesito su apoyo para que me puedan indicar porque no accede un formulario de login en JSCRIPT,al momento de ingresar el login y el password se queda pensando, y nunca autentica a los usuarios. creo que con eso describo todo. les muestro el codigo del archivo login.js.
Código Javascript:
Ver original
  1. var loadMask = function()
  2. {
  3.     return {
  4.         init : function(){
  5.             // Creamos el cargador
  6.  
  7.             var loading = Ext.get('loading');
  8.             var mask = Ext.get('loading-mask');
  9.             mask.setOpacity(0.8);
  10.             mask.shift(
  11.                 {
  12.                     xy:loading.getXY(),
  13.                     width:loading.getWidth(),
  14.                     height:loading.getHeight(),
  15.                     remove:true,
  16.                     duration:1,
  17.                     opacity:0.3,
  18.                     easing:'bounceOut',
  19.                     callback : function()
  20.                     {
  21.                         // Desvanece cuando la carga termina
  22.                         loading.fadeOut(
  23.                             {
  24.                                duration:0.2,remove:true
  25.                             }
  26.                         );
  27.                     }
  28.                 }
  29.             );
  30.         }
  31.     }
  32.     ;
  33. }
  34. ();
  35.  
  36. Ext.onReady(loadMask.init, loadMask, true);
  37. Ext.onReady(function()
  38.  
  39.     {
  40.            Ext.form.VTypes["phone"] = /0[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/;
  41.            Ext.form.VTypes["phoneText"] = 'No es Un codigo valido';
  42.  
  43.         Ext.QuickTips.init();
  44.         Ext.form.Field.prototype.msgTarget = 'side';
  45.         // Usamos un FormPanel para crear la caja de Login
  46.  
  47.         var login = new Ext.FormPanel({
  48.  
  49.             labelWidth: 60,
  50.             url: "login.php",
  51.             frame: true,
  52.             title: 'Iniciar sesion',
  53.  
  54.             width: 230,
  55.             padding: 0,
  56.             defaultType: 'textfield',
  57.             monitorValid: true,
  58.  
  59.             items:  {
  60.  
  61.             xtype:'tabpanel',
  62.             activeTab: 0,
  63.             defaults:{autoHeight:true, bodyStyle:'padding:5px'},
  64.  
  65.             items:[{
  66.                 title:'Login',
  67.                 layout:'form',
  68.                 defaults: {width: 200},
  69.                 defaultType: 'textfield',
  70.  
  71.                     items: [{
  72.                     fieldLabel: 'Usuario',
  73.                     name: 'user',
  74.                     allowBlank:false,
  75.                     vtype: 'phone',
  76.                     maxLength     : 10
  77.  
  78.                 },{
  79.                     fieldLabel: 'Password',
  80.                     name: 'password',
  81.                     id: 'password',
  82.                     inputType: 'password',
  83.                     allowBlank:false
  84.  
  85.                   }]
  86.             }
  87.  
  88.             ]
  89.         },
  90.             buttons: [{
  91.                 text: 'Ingresar',
  92.                 formBind: true,
  93.                 handler: function()
  94.                 {
  95.                     login.getForm().submit({
  96.                         method: 'POST',
  97.                         waitTitle: 'Autenticando..',
  98.                         waitMsg: 'Enviando datos...',
  99.                         success: function(form,action)//acciona el boton depende a la peticion a la base de datos
  100.                         {
  101.                            switch(action.result.usertype)
  102. //el switch direccion depende al tipo de usuario el cual ingreso
  103.                             {
  104.                             case 1:
  105.                              var redirect = "../Main/index.php";
  106.                             window.location = redirect;
  107.                             // va para la pagina uno
  108.                             break;
  109.                             default:
  110.                             }
  111.  
  112.                         },
  113.  
  114.                         failure: function(form, action)
  115.                         // Pero si falla
  116.                         {
  117.                             if (action.failureType == 'server')
  118.                             {
  119.                                 obj = Ext.util.JSON.decode(action.response.responseText);
  120.                                 Ext.Msg.alert('Intenta de nuevo!', obj.errors.reason);
  121.                                 // Le decimos al usuario que el logueo falló y le damos el motivo
  122.                             }
  123.                             else
  124.                             {
  125.                                 Ext.Msg.alert('Ouch!', 'el servidor no contesta : ' + action.response.responseText);
  126.                                 // O bien si hubo algún error en el sistema
  127.                             }
  128.                             login.getForm().reset();
  129.                         }
  130.                     });
  131.                 }
  132.             }]
  133.         });
  134.         // Usamos un Window para mostrar el Login en una ventanita
  135.  
  136.         var win = new Ext.Window(
  137.             {
  138.  
  139.                 layout: 'fit',
  140.                 width: 370,
  141.                 height: 175,
  142.                 closable: false,
  143.                 resizable: false,
  144.                 plain: true,
  145.                 items: [login] // y acá cargamos el panel con el login
  146.  
  147.             }
  148.         );
  149.         win.show();
  150.  
  151.     }
  152. );

el archivo login.php
Código PHP:
Ver original
  1. <?php
  2. include("../conexion/cnx_php.php");
  3. //obtenemos los valores de nuestro login
  4. $user = $_REQUEST['user'];
  5. $pass = $_REQUEST['password'];
  6. $result = mssql_query("select login,password from SRM_login where login= '$user' and password = '$pass'");
  7. $row = mssql_fetch_array($result);
  8.  
  9. //echo "$user";
  10.  //preguntamos si es que existe
  11. if($row['login'] != $user && $row['password'] != $pass)
  12. {
  13.      echo "{success: false, errors: { reason: 'Password error.' }}";
  14.  
  15. }
  16. else{
  17.     if(is_numeric($user) and strlen($user)==10)
  18.     {
  19.       //mandamos el valor 1 al switch que esta en nuestro archiv.js para direccionar
  20.          echo "{success: true, usertype: 1}";
  21.     }
  22.     }
  23.  
  24. ?>

y el archivo cnx_php.php
Código PHP:
Ver original
  1. <?php
  2. mssql_connect('(local)', 'USR', 'PWD') or die("No fue posible conectar con el servidor");
  3. mssql_select_db('DB') or die("No fue posible selecionar la base de datos");
  4. ?>