Ciao a tutti =),sto provandoa costruire un'area utenti...ho creato il database in access e questo è il codice che son riuscita a fare in ASP,solo che ho un problema, mi riconosce come validi ogni password e username, non solo quelli inseriti nel database.Qualcuno può dirmi dove ho sbagliato?grazie a tutti![]()
<%@LANGUAGE = JScript%>
<%
var azione = new String(Request.QueryString("azione"));
%>
<html>
<head>
<title>Login</title>
</head>
<body>
<%
if (azione == "OK")
{
var username = new String(Request.Form("username"));
var password = new String(Request.Form("password"));
var username2 = username.replace(/'/g,"''");
var password2 = password.replace(/'/g,"''");
var Cn = new ActiveXObject("ADODB.Connection");
Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("database.mdb"));
var Sql = "SELECT * FROM utenti WHERE username = '" + username2 + "' AND password = '" + password2 + "'";
var EseguiLogin = Cn.Execute(Sql);
if (EseguiLogin.EOF)
{
Cn.Close();
Response.Write("ACCESSO NEGATO");
Response.End;
}
else
{
Cn.Close();
Session("username") = username;
with (Response)
{
Write("<p align='center'>");
Write("Benvenuto " + username + "!
");
Write("Clicca qui per entrare!");
Write("</p>");
}
}
}
else
{
%>
<p align="center">
<form method="post" action="privata.html">
Username
<input type="text" name="username">
Password
<input type="password" name="password">
<input type="submit" value="Login">
</form>
</p>
<%
}
%>
</body>
</html>