我希望如下:new form
<%
oldUsername=QS_CLEAR(request.QueryString("s1"))
oldPassword=request.QueryString("s2")
newUsername=QS_CLEAR(request.QueryString("nu"))
newPassword=request.QueryString("np1")
newComfirm=request.QueryString("np2")
if oldUsername="" or oldPassword="" or newUsername="" or newPassword="" or newComfirm="" then
response.Write("<div id=""hata"">Fill the form correctly.</div>")
elseif QS_CLEAR(newPassword)<>QS_CLEAR(newComfirm) then
response.Write("<div id=""hata"">New passwords do not match.</div>")
else
rst.open "SELECT * FROM Users WHERE (Type='T') AND (username='"&username&"') and (UserID<>"&ID&")",conn,3,3
if rst.eof then
rst.close:rst.open "SELECT * FROM Users WHERE ID="&session("UserID"),conn,3,3
if lcase(rst("username"))<>lcase(oldUsername) then
response.Write("<div id=""hata"">Your username is wrong.</div>")
elseif encode(lcase(oldUsername)&oldPassword&lcase(mid(cstr(rst("GUID")),2,36)))<>rst("Password") then
response.Write("<div id=""hata"">Your password is wrong.</div>")
else
GUID=lcase(GetGuid()):password=encode(lcase(oldUsername)&newPassword&GUID)
rst("Username")=newUsername:rst("Password")=password:rst("GUID")="{"&GUID&"}"
rst.update
response.Write("<div id=""basarili"">Your password has changed.</div>")
end if
else
response.Write("<div id=""hata"">You can not choose this username.</div>")
end if
rst.close
end if
%>
我应该在上面的代码中做出哪些更改才能使其正常工作。
答案 0 :(得分:0)
以下未经测试的代码:
添加了一些评论,请询问您是否需要更多信息或是否有任何错误
<%
'we have only three inputs now,
oldPassword=request.QueryString("s2")
newPassword=request.QueryString("np1")
newComfirm=request.QueryString("np2")
Response.write "oldPassword = " & oldPassword & "<br>";
Response.write "newPassword = " & newPassword & "<br>";
Response.write "newComfirm = " & newComfirm & "<br>";
if oldPassword="" or newPassword="" or newComfirm="" then
response.Write("<div id=""hata"">Fill the form correctly.</div>")
elseif QS_CLEAR(newPassword)<>QS_CLEAR(newComfirm) then
response.Write("<div id=""hata"">New passwords do not match.</div>")
else
Dim sql : sql = "SELECT * FROM Users WHERE ID="&session("UserID")
Response.write "sql=" & sql & "<br>"
rst.open sql,conn,3,3
if NOT rst.EOF
'check if the old password provided is correct.Use rst("Username") instead of oldUsername
if encode(lcase(rst("Username"))&oldPassword&lcase(mid(cstr(rst("GUID")),2,36)))<>rst("Password") then
response.Write("<div id=""hata"">Your password is wrong.</div>")
else
GUID=lcase(GetGuid())
password=encode(lcase(rst("Username")&newPassword&GUID)
rst("Password")=password
rst("GUID")="{"&GUID&"}"
'add changed date, may need some tweaking for the required format.
rst("PasswordChanged") = Now
rst.update
response.Write("<div id=""basarili"">Your password has changed.</div>")
end if
end if
rst.close
end if
%>