Forums
This topic is locked
ASP - Change Password
Posted 07 Nov 2001 21:54:59
1
has voted
07 Nov 2001 21:54:59 Chris Fuller posted:
I'm trying to add a change password ASP page to my site. I want to have a field for the old password, a field for the new password and another field to confirm the password (like the one on this message board - under Edit Profile). A bit like this:Old Password: [txtOldPassword]
New Password: [txtNewPassword]
Confirm New Password [txtConfirmPassword]
Then I want the ASP to check the id recordset in the database, verify that the password field (id-password) in the database is = txtOldPassword and then change is to txtNewPassword.
Any ideas? Help greatly appreciated.
BTW - I'm using Dreamweaver Ultra Dev
Cheers
Chris
Replies
Replied 07 Nov 2001 23:06:13
07 Nov 2001 23:06:13 Some One replied:
take a loo this code and get inspiration...
Aşll the things going on P13 Pass Changer....
<%'*** P13 Pass Changer
If (false) or (CStr(Request("MM_insert") <> "" or (CStr(Request("MM_update") <> "" Then
Dim p13passold, p13passst, p13passsc, p13memberid, p13hellsame, p13hellnone
p13hellsame = "sifredegistir.asp?msj=4" '** Redirect if new passes wrong !
p13hellnone = "sifredegistir.asp?msj=3" '** Redirect if old pass wrong !
p13passold = Request.Form("eski"
p13passst = Request.Form("yeni"
p13passsc = Request.Form("yeni2"
p13memberid = logok.Fields.Item("uye_id".Value
if p13passst <> p13passsc then '* equal check
Response.Redirect(p13hellsame)
End if
if p13passold <> logok.Fields.Item("sifre".Value then
Response.Redirect(p13hellnone)
End if
End if'P13 Pass Changer
%>
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_zafer_STRING
MM_editTable = "uyeler"
MM_editColumn = "uye_id"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "logout.asp?msj=3&sayfa=login.asp?msj=3"
MM_fieldsStr = "yeni|value"
MM_columnsStr = "sifre|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
set logok = Server.CreateObject("ADODB.Recordset"
logok.ActiveConnection = MM_zafer_STRING
logok.Source = "SELECT * FROM uyeler WHERE kullanici = '" + Replace(logok__MMColParam, "'", "''" + "'"
logok.CursorType = 0
logok.CursorLocation = 2
logok.LockType = 3
logok.Open()
%>
<html>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" vlink="#000000" link="#000000" alink="#000000" scroll="auto">
<!--#include file="header.asp" -->
<table border="0" cellspacing="0" cellpadding="2" align="center" width="750">
<tr>
<td bgcolor="#330066"><img src="images/na13.gif" width="165" height="5"></td>
<td bgcolor="#6D3F3A"><img src="images/na13.gif" width="410" height="5"></td>
<td bgcolor="#330066"><img src="images/na13.gif" width="150" height="5"></td>
</tr>
<tr valign="top">
<td>
<br>
</td>
<td>
<table width="98%" border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF">
<form name="passremind" method="POST" action="<%=MM_editAction%>">
<tr bgcolor="#f7f7f7">
<td nowrap colspan="2" class="baslik"><img src="images/na13.gif" width="5" height="5" border="1" class="boxabone" hspace="2">
Şifrenizi Değiştirin</td>
</tr>
<tr>
<td colspan="2">
<p>
<%if Request.Querystring("msj" = "4" Then'P13st%>
<font color="#FF0000">Yeni girdiğiniz şifreler birbirini tutmuyor
!</font>
<%End if'P13MSG%>
<%if Request.Querystring("msj" = "3" Then'P13st%>
<font color="#FF0000">Şifrenizi yanlış girdiniz lütfen tekrar
deneyin !</font>
<%End if'P13MSG%>
</p>
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Eski Şifreniz</font></b></td>
<td width="63%"><b><font color="#FF6600"> :</font></b>
<input type="password" name="eski" maxlength="255">
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Yeni Şifreniz</font></b></td>
<td width="63%"> <b><font color="#FF6600"> :</font></b>
<input type="password" name="yeni" maxlength="255">
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Yen Şifreniz (Tekrar)</font></b></td>
<td width="63%"><b><font color="#FF6600"> :</font></b>
<input type="password" name="yeni2" maxlength="255">
</td>
</tr>
<tr align="center">
<td nowrap colspan="2">
<hr size="1" color="#0A5287">
<input type="submit" name="Button22" value="Tamam">
</td>
</tr>
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%= logok.Fields.Item("uye_id".Value %>">
</form>
</table>
</td>
<td> </td>
</tr>
</table>
sdi ::: pixels to blood
Aşll the things going on P13 Pass Changer....
<%'*** P13 Pass Changer
If (false) or (CStr(Request("MM_insert") <> "" or (CStr(Request("MM_update") <> "" Then
Dim p13passold, p13passst, p13passsc, p13memberid, p13hellsame, p13hellnone
p13hellsame = "sifredegistir.asp?msj=4" '** Redirect if new passes wrong !
p13hellnone = "sifredegistir.asp?msj=3" '** Redirect if old pass wrong !
p13passold = Request.Form("eski"
p13passst = Request.Form("yeni"
p13passsc = Request.Form("yeni2"
p13memberid = logok.Fields.Item("uye_id".Value
if p13passst <> p13passsc then '* equal check
Response.Redirect(p13hellsame)
End if
if p13passold <> logok.Fields.Item("sifre".Value then
Response.Redirect(p13hellnone)
End if
End if'P13 Pass Changer
%>
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_zafer_STRING
MM_editTable = "uyeler"
MM_editColumn = "uye_id"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "logout.asp?msj=3&sayfa=login.asp?msj=3"
MM_fieldsStr = "yeni|value"
MM_columnsStr = "sifre|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none" Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none" Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none" Then EmptyVal = ""
If (FormVal = "" Then
FormVal = EmptyVal
Else
If (AltVal <> "" Then
FormVal = AltVal
ElseIf (Delim = "'" Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''" & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
set logok = Server.CreateObject("ADODB.Recordset"
logok.ActiveConnection = MM_zafer_STRING
logok.Source = "SELECT * FROM uyeler WHERE kullanici = '" + Replace(logok__MMColParam, "'", "''" + "'"
logok.CursorType = 0
logok.CursorLocation = 2
logok.LockType = 3
logok.Open()
%>
<html>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" vlink="#000000" link="#000000" alink="#000000" scroll="auto">
<!--#include file="header.asp" -->
<table border="0" cellspacing="0" cellpadding="2" align="center" width="750">
<tr>
<td bgcolor="#330066"><img src="images/na13.gif" width="165" height="5"></td>
<td bgcolor="#6D3F3A"><img src="images/na13.gif" width="410" height="5"></td>
<td bgcolor="#330066"><img src="images/na13.gif" width="150" height="5"></td>
</tr>
<tr valign="top">
<td>
<br>
</td>
<td>
<table width="98%" border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF">
<form name="passremind" method="POST" action="<%=MM_editAction%>">
<tr bgcolor="#f7f7f7">
<td nowrap colspan="2" class="baslik"><img src="images/na13.gif" width="5" height="5" border="1" class="boxabone" hspace="2">
Şifrenizi Değiştirin</td>
</tr>
<tr>
<td colspan="2">
<p>
<%if Request.Querystring("msj" = "4" Then'P13st%>
<font color="#FF0000">Yeni girdiğiniz şifreler birbirini tutmuyor
!</font>
<%End if'P13MSG%>
<%if Request.Querystring("msj" = "3" Then'P13st%>
<font color="#FF0000">Şifrenizi yanlış girdiniz lütfen tekrar
deneyin !</font>
<%End if'P13MSG%>
</p>
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Eski Şifreniz</font></b></td>
<td width="63%"><b><font color="#FF6600"> :</font></b>
<input type="password" name="eski" maxlength="255">
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Yeni Şifreniz</font></b></td>
<td width="63%"> <b><font color="#FF6600"> :</font></b>
<input type="password" name="yeni" maxlength="255">
</td>
</tr>
<tr>
<td nowrap width="25%"><b><font color="#FF6600">Yen Şifreniz (Tekrar)</font></b></td>
<td width="63%"><b><font color="#FF6600"> :</font></b>
<input type="password" name="yeni2" maxlength="255">
</td>
</tr>
<tr align="center">
<td nowrap colspan="2">
<hr size="1" color="#0A5287">
<input type="submit" name="Button22" value="Tamam">
</td>
</tr>
<input type="hidden" name="MM_update" value="true">
<input type="hidden" name="MM_recordId" value="<%= logok.Fields.Item("uye_id".Value %>">
</form>
</table>
</td>
<td> </td>
</tr>
</table>
sdi ::: pixels to blood
Replied 08 Nov 2001 20:57:35
08 Nov 2001 20:57:35 Chris Fuller replied:
Err, thanks very much. But I am new to all this ASP/UltraDev stuff. So if you could explain what's going on then that would be appreciated.
Perhaps a better explanation on my part would be helpful:
In the databse there is:
id
--id (autonumber)
--userName (text)
--password (text)
Is it possible to check the users entry for txtOldPassword against id/password, then check that the field txtNewPassword = txtConfirmNewPassword, before updating the id/password field in the database?
I've only had limited experience with VB so far, so simple explanations appreciated!
Thanks once again
Chris
Perhaps a better explanation on my part would be helpful:
In the databse there is:
id
--id (autonumber)
--userName (text)
--password (text)
Is it possible to check the users entry for txtOldPassword against id/password, then check that the field txtNewPassword = txtConfirmNewPassword, before updating the id/password field in the database?
I've only had limited experience with VB so far, so simple explanations appreciated!
Thanks once again
Chris