Ciao a tutti sto provando a creare un form per il recupero password di un utente registrato in database access. Ci sono 2 listati (recupera_password2.asp e inc_viewuser2.asp).
Nella pagina recupera_password2.asp è inclusa l' altra ed è presente anche il form dove l' utente inserisce l' username e l' email.
All' utilizzo le opzioni che si dovrebbero prospettare sono la conferma di invio password oppure l' avviso di username / email errati.
Provando in locale succede questo:
1) Scrivendo username e email corretti (del primo record del database) i dati vengono trovati ma si ritorna al form di inserimento degli stessi e non il messaggio di conferma invio email
2) Scrivendo username e email corretti (del secondo o altri records del database) i dati non vengono trovati e si ritorna al form di inserimento degli stessi con l' avviso di username / email errati.
Ciao a tutti e grazie in anticipo
qui sotto metto il codice:
recupera_password2.asp (PAGINA COL FORM)
<%
If Request.QueryString("step") = "2" Then
Response.Redirect("recupera_password2.asp?step=3&u serMember_id=" & getuserMember_id(Request.Form("M_name"), Request.Form("M_Email")))
ElseIf Request.QueryString("step") = "3" AND Request.QueryString("Member_id") <> "" Then
MailOrder = "info@miosito.it" 'Indirizzo mittente ordini
strSender = MailOrder
strFromName = pageTitle & " Case in Sardegna"
strFromEmail = adminEmail
strRecipientsEmail = rs_viewuser("M_Email")
strRecipientsName = rs_viewuser("M_Name")
strSubject = pageTitle & " Password Reminder"
strMessage = "Recupero password" & vbCrLf & _
strRecipientsName & ", Le informazioni da lei richieste:" & vbCrLf & vbCrLf & _
"Username: " & rs_viewuser("M_Name") & vbCrLf & _
"Password: " & rs_viewuser("M_Password") & vbCrLf & vbCrLf & _
"Grazie per averci scelto," & vbCrLf & pageTitle & ""
Dim objMessage, iConf, Flds
Set objMessage = CreateObject("CDO.Message")
objMessage.From = strSender
'objMessage.Sender = strSender
objMessage.TextBody = strMessage
objMessage.To = strRecipientsEmail
objMessage.Subject = strSubject
objMessage.Send
Set iConf = CreateObject("CDO.Configuration")
'Impostazione delle configurazioni per l'invio remoto
Set Flds = iConf.Fields
Set .Configuration = iConf
Flds("http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion") = True
If Err <> 0 Then
Err_Msg = Err_Msg & "[*]Impossibile spedire l'email. Errore: " & Err.Description & ""
End if
On Error Resume Next
Set objNewMail = Nothing
set Flds = Nothing
set iConf = Nothing
On Error Goto 0
mailSent = True
ElseIf Request.QueryString("step") = "3" AND Request.QueryString("userMember_id") = "" Then
mailSent = False
emptyValue = True
Else
mailSent = False
End If
%>
<title><%=pageTitle%> - Recupera Password</title>
<% If mailSent = False Then %>
<% If emptyValue = True Then %>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body bgcolor="#DFDFDF"><p align="center">Combinazione Username/Email non valida</p>
<% End If %>
<form name="pwForm" method="post" action="recupera_password2.asp?step=2">
<table width="412" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="35" colspan="2" align="center"><font size="5">Inserisci
username e email</font></td>
</tr>
<tr>
<td colspan="2" height="4"></td>
</tr>
<tr>
<td width="30%">Username</td>
<td width="70%"><input name="M_name" type="text" id="M_Name" size="35"></td>
</tr>
<tr>
<td colspan="2" height="4"></td>
</tr>
<tr>
<td width="30%">Email</td>
<td width="70%"><input name="M_Email" type="text" id="M_Email" size="35"></td>
</tr>
<tr>
<td colspan="2" height="4"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Submit">
<input name="Reset" type="reset" id="Reset" value="Reset"></td>
</tr>
</table>
</form>
<% Else %>
<p align="center">Username e Password ti sono state spedite per email.</p>
<% End If %>
inc_viewuser2.asp (PAGINA CHE E' INCLUSA NELL' ALTRA)
<%
Function rs_viewuser(desField)
If Request.QueryString("userMember_id") <> "" Then
viewuserSQL = "SELECT * FROM Members WHERE Member_id='" & Request.QueryString("userMember_id") & "'"
Else
viewuserSQL = "SELECT * FROM Members WHERE Member_id='" & str_users_Member_id & "'"
End If
Set RS = Server.CreateObject ("ADODB.RecordSet")
RS.Open viewuserSQL,cString
retField = RS(desField)
RS.Close
Set RS = Nothing
rs_viewuser = retField
End Function
Function getuserMember_id(M_Name, M_Email)
viewuserSQL = "SELECT * FROM Members WHERE M_Name='" & M_Name & "' AND M_Email='" & M_Email & "'"
Set RS = Server.CreateObject ("ADODB.RecordSet")
RS.Open viewuserSQL,cString
If RS.EOF Then
retMember_id = ""
Else
retMember_id = RS("Member_id")
End If
RS.Close
Set RS = Nothing
getuserMember_id = retMember_id
End Function
%>