Grazie 1000, ce l'ho fatta!
Se può servire a qualcuno il codice è questo:
Codice PHP:
<%
Option Explicit
'--- Prevent caching
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "cache-control", "must-revalidate"
Response.AddHeader "cache-control", "private"
Response.AddHeader "pragma", "no-cache"
Session.Timeout = 20
%>
<%
'--- Define variables
Dim sReferer, sGoBackTo, sUserName, sPassword, bLoginSuccessful, Error
if request.querystring("comebackto") <> "" then
sReferer = request.querystring("comebackto")
sGoBackTo = "?" & request.querystring
end if
'--- If Login Form has been submitted
if request.form("Status") = "FormSubmitted" then
sUserName = replace(request.form("txtUserName"),"'","")
sPassword = replace(MD5(request.form("txtPassword")),"'","")
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open strDB
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
Dim strSql
strSQL="SELECT * FROM TB_UTENTI WHERE user ='"& sUserName &"' AND pass = '"& sPassword &"'"
rs.Open strSQL,cn
'--- Check for username and password match
If not rs.EOF then
bLoginSuccessful = True
Rs.close
set Rs = nothing
cn.close
set cn = nothing
Else
bLoginSuccessful = False
Error = "Username o password errati!"
'--- Send user to the default page after 3 unsuccessful try
Session("count") = Session("count") + 1
if Session("count") > 3 then
Session.abandon
response.redirect sGoBackTo
End if
End if
Session("bLoginSuccessful") = bLoginSuccessful
End if
'--- After a successful login, let's send the user back to see the protected page
'--- The variable sReferer holds the page to go back,
'--- if it is empty, the user is redirected to the default page
if bLoginSuccessful Then
if sReferer = "" then
response.redirect "../"
else
response.redirect sReferer
end if
else
'--- If no login performed then display the Login Form
%>
<link rel="stylesheet" type="text/css" href="stile.css">
<table width="743" border="0" align="center" cellpadding="0" cellspacing="10" bgcolor="#000000">
<tr>
<td class="cerca">
<p align=center>
[b]<font size="2" color="#FFD80C">Per entrare nell area di modifica è necessario effettuare il riconoscimento!</font>[/b]
</p>
</td>
</tr>
<tr>
<%
'--- Show error when credentials are incorrect
if Error <> "" then
response.write "<td colspan=2 align=center class=cerca bgcolor=#000000><font color=red size=2>" & Error
response.write "</font>
</td></tr><tr>"
End if
%>
<td align="center" height="80" class="cerca">
<form action="login.asp<%=sGoBackTo%>" method="post" name="Login">
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#000000" class="cerca"><tr>
<td align="right">[b]<font color="red">*</font>User name:[/b]</td>
<td><input type="Text" name="txtUserName" size="30" class="inputclass"></td>
</tr><tr>
<td align="right">[b]<font color="red">*</font>Password:[/b]</td>
<td><input type="Password" name="txtPassword" size="30" class="inputclass"></td>
</tr><tr>
<td colspan="2" height=30 class=cerca align=right>
<input type="submit" name="cmdLogin" value="Login" class="buttonclass">
<input type="hidden" name="Status" value="FormSubmitted">
</td></tr></table>
</p><div align="center">[b][url="default.asp"]Torna alla Home[/url][/b]</div>
</p></form></td></tr>
</table>
<% End if
%>