Ecco il codice
<%@ LANGUAGE = JScript %>
<%
function visualizzaErrore(messaggioDiErrore) {
// Mostra il messaggio di errore e interrompe il programma
Response.Write('<html>\n');
Response.Write('<head>\n');
Response.Write('<title>Iscrizione al servizio</title>\n');
Response.Write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n');
Response.Write('</head>\n');
Response.Write('<body bgcolor="#FFFFFF" text="#000000">\n');
Response.Write('<div align="center">\n');
Response.Write('<p> </p>\n');
Response.Write('<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#660000">');
Response.Write('ERRORE: ' + messaggioDiErrore);
Response.Write('</font></b></p>\n');
Response.Write('<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">[<a href="#" onClick="history.back()">TORNA INDIETRO</a>]</font></p>\n');
Response.Write('</div>\n');
Response.Write('</body>\n');
Response.Write('</html>\n');
Response.End;
}
username = String(Request.Form("username"));
password1 = String(Request.Form("password1"));
password2 = String(Request.Form("password2"));
if (username=="" || username=="undefined") visualizzaErrore("SPECIFICARE LO USERNAME");
if (username.charAt(0)==" ") visualizzaErrore("HAI INSERITO UNO SPAZIO DI TROPPO PRIMA DELLO USERNAME");
if (username.charAt(username.length-1)==" ") visualizzaErrore("HAI INSERITO UNO SPAZIO DI TROPPO DOPO LO USERNAME");
if (username.length<3 || username.length>20) visualizzaErrore("LO USERNAME DEVE ESSERE COMPRESO TRA 3 E 20 CARATTERI");
if (password1=="" || password1=="undefined") visualizzaErrore("SPECIFICARE LA PASSWORD");
if (password1!=password2) visualizzaErrore("LE DUE PASSWORD NON COINCIDONO");
if (password1.length<3 || password1.length>20) visualizzaErrore("LA PASSWORD DEVE ESSERE COMPRESA TRA 3 E 20 CARATTERI");
ADOConn = new ActiveXObject("ADODB.Connection");
strConn = "";
strConn += "driver={Microsoft Access Driver (*.mdb)};";
strConn += "dbq=" + Server.MapPath("utenza.mdb") + ";";
strConn += "pwd=201179";
ADOConn.Open(strConn); QUESTA E' LA RIGHA DI ERRORE
tempUsername = username.replace(/'/g,"''");
sql = "SELECT * FROM utenti WHERE username LIKE '" + tempUsername + "'";
ris = ADOConn.Execute(sql);
if (!ris.EOF) {
ris.Close();
ADOConn.Close();
visualizzaErrore("LO USERNAME SPECIFICATO GIA' RISULTA IN USO. MODIFICARE LA PROPRIA SCELTA.");
}
ris.Close();
RecSet = new ActiveXObject("ADODB.Recordset");
RecSet.Open("utenti",ADOConn,3,3);
RecSet.AddNew();
RecSet("username") = username;
RecSet("password") = password1;
RecSet.Update();
RecSet.Close();
ADOConn.Close();
%>
<html>
<head>
<title>Iscrizione al servizio riuscita!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<p><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">COMPLIMENTI, ORA SEI ISCRITTO!</font></b></p>
</div>
</body>
</html>