Se carichi tutti gli username in un array e lo spedisci al client dimezzi il lavoro degli hacker... devono solo trovare le eventuali password.
Inoltre spedisci ogni volta qualche (pochi? tanti? dipende ) k di dati ridondanti al browser, appesantendo la rete e caricando inutilmente server e browser.
Ti posto un esempio minimo in ajax: devi aggiungere una pagina lato server che esegua la verifica della presenza/asssenza dell'utente nel db e restituisca un semplice "OK" o qualcos'altro a seconda dei casi
ciaocodice:<script type="text/javascript"> function createXMLHttp() { var xmlhttp ; try { xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7 } catch (e) { var MSXML_XMLHTTP_PROGIDS = new Array( 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', // Internet Explorer 6 'Microsoft.XMLHTTP' // Internet Explorer 4,5 ); var success = false; for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) { try { xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); success = true; } catch (e) {} } if ( !success ) { alert('Cant create XMLHttpRequest - not supported'); } } return xmlhttp; } var xmlHttpTesto=""; function getText(qry) { xmlHttpTesto=""; var xmlHttpObj = null; xmlHttpObj=createXMLHttp(); xmlHttpObj.open('get', qry, false); // false=sincrono xmlHttpObj.onreadystatechange = function() { if (xmlHttpObj.readyState == 4) { if (xmlHttpObj.status==200 || xmlHttpObj.status==304) { xmlHttpTesto = xmlHttpObj.responseText; } else { alert("connessione perduta - ricaricare la pagina"); return; } } } xmlHttpObj.send(null); delete xmlHttpObj; } function verifica(s) { getText('verificautente.asp?ut='+s) if (xmlHttpTesto!="") { if (xmlHttpTesto!="OK") { alert("Nome Utente gia' Usato"); } } } </script> </head><body> .... <input type="text" size="15" name="utente" value="" onblur="verifica(this.value)">

Rispondi quotando