Salve ho creato un sistema di login in asp strutturato nel seguente modo:
pagina login.asp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CaudiumBook | Benvenuto</title>
<style type="text/css">
<!--
#contenitore #menu table tr th {
font-size: 36px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenitore">
<div id="menu">
<table width="955" height="50" border="0" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"></th>
</tr>
</table>
</div>
<div id="contenuto">
<FORM ACTION="login1.asp" METHOD="POST">
<TABLE ALIGN=CENTER BORDER=0 BGCOLOR=#000000>
<TR BGCOLOR=#EEEEEE>
<TD WIDTH=150 ALIGN=CENTER>NOME UTENTE</td>
<TD>
<INPUT TYPE=TEXT NAME="nome_utente" SIZE=20>
</td>
</TR>
<TR BGCOLOR=#EEEEEE>
<TD WIDTH=150 ALIGN=CENTER>PASSWORD</td>
<TD>
<INPUT TYPE=PASSWORD NAME="password" SIZE=20>
</TD>
</TR>
<TR BGCOLOR=#EEEEEE>
<TD HEIGHT=30 COLSPAN=2 ALIGN=CENTER>
<INPUT TYPE=SUBMIT NAME="show" VALUE="LOGIN">
</TD>
</TR>
</TABLE>
</FORM>
</div>
</div>
</body>
</html>
poi ho creato una pagina login1.asp
nella quale verifica ke nome utente e password sono presenti nel database..
Pagina login1.asp
<%
dim user, pass, errore, risposta
user = Replace(Request.Form("nome_utente"), "'", "''")
pass = Replace(Request.Form("password"), "'", "''")
errore = false
if user = "" or isempty(user) then
errore = true
response.redirect "errore_user_pas.html"
'risposta = "Inserisci un USERNAME corretto!!"
elseif pass = "" or isempty(pass) then
errore = true
'risposta = "Inserisci una PASSWORD corretta!!"
end if
if errore = true then
response.redirect "errore_user_pas.html"
else
dim cn
set cn = server.createobject("ADODB.Connection")
cn.open "DRIVER={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("/mdb-database/registrazione.mdb")
dim rs
set rs = server.createobject("ADODB.Recordset")
dim sql
sql = ""
sql = sql & "SELECT * FROM Utenti "
sql = sql & "WHERE Username = '" & user & "'"
sql = sql & " AND Password = '" & pass & "'"
rs.open sql, cn, 3, 3
dim valido
valido = true
if errore = true or rs.eof then
valido = false
end if
if valido = true then
dim sessione
sessione = rs("Username")
dim data
data = date()
rs("visita") = data
rs.update
session("utente") = sessione
rs.close
set rs = nothing
cn.close
set cn = nothing
response.redirect("areautenti.asp")
end if
end if
%>
il mio problema è ke quando la password o il nome utente nn è presente o entrimbi rimango nella pagina login1.asp iinvece di fare il redirect ad errore_user_pas.html

Rispondi quotando