in effetti non è venuto un gran che!!!
Sostanzialmente l'area riservata funziona.
Però vorrei che se un utente cerca di connettersi ad una pagina riservata venga rispedito alla login.
Una volta reinserito i dati l'utente dovra accedere alla pagina che aveva scelto!!
Invece mi accede sempre alla pagina del dopo login!!!
Ecco il codice della pagina login:
codice:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
errore = false
Response.Write(errore)
tempusername = Request.Form("username")
temppassword = Request.Form("password")
from = Request.QueryString("from")
if not(tempusername="undefined" or tempusername="" ) Then
from = Request.Form("from")
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
str = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" & Server.MapPath("automobili.mdb") &"; Persist Security Info = False"
conn.open str
set Ris=conn.execute("select * from Anagrafe WHERE username='"& tempusername &"' AND password='"& temppassword &"'")
set Ris1=conn.execute("select * from Amministratori WHERE username='"& tempusername &"' AND password='"& temppassword &"'")
if Ris.Eof Then
errore = true
Else
Session.Timeout = 15
Session("username") = Ris("username")
ris.Close()
if not(from="") Then
Response.Redirect (from)
else
Response.Redirect("main.asp")
End if
End if
if Ris1.Eof Then
errore = true
Else
Session.Timeout = 15
Session("username") = Ris1("username")
ris.Close()
if not (from="") Then
Response.Redirect ("from")
else
Response.Redirect("index.asp")
End if
End if
End if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
ATTENZIONE! STAI PER ACCEDERE AD UN'AREA RISERVATA. DEVI AUTENTIFICARTI.
</font>[/b]</p>
<% if (errore) then%>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FF0000">
DATI NON TROVATI, ACCESSO NEGATO</font></p>
<% End if %>
<%Response.Write(errore)%>
<form name="form1" method="post" action="login.asp">
<input type="hidden" name="from" value="<%=from%>">
<div align="center">
Username
<input type="text" name="username">
</p>
Password
<input type="text" name="password">
</p>
<input type="submit" name="Submit" value="Invia">
</p>
</div>
</form>
</body>
</html>
Mentre questa è una qualsiasi pagina riservata:
codice:
<%
if (Session("username")="") then
from = Request.ServerVariables("SCRIPT_NAME")
Response.Redirect("login.asp?from=" + from)
End if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
PAGINA RISERVATA
</body>
</html>