472,146 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Code for Change password in ASP for Windows XP, IIS server

Hi
Iam facing a problem in my project, developing a web site for online shopping in ASP on windows XP using IIS server.
All the validations are ok but the new password is not upadated in the data base and also showing a error page.

the operating system we used is Windows XP,
the source code is ASP,
front end we used - HTML and
javascript and vb script for validations.
the inputs we used are :
old pasword :
new password :
confirm your new password :
and SUBMIT button

we have used two files
in first page we give option for changepassword when the user clicks this option then he gets the page with above mentioned inputs , this is all written in one file changepass.asp the code of the file changepass.asp is as follows:
<%
'option explicit
Response.Buffer = True
Response.Expires = 0
%>

<html>
<head>
<title> Login Screen </title>
</head>
<body>
<form name="login" action="changepass2.asp" method="post">
<input type=button value=" <<BACK " name=butt1 onClick="window.location='login.asp'">
<table align=center border=3 cellpadding="3" cellspacing=0>

<tr>
<th colspan=2 bgcolor=black>
<font face=verdana color=red size=+1><b> Change Password </font>
</th>
</tr>

<tr>
<td>
<font face=verdana><b>Enter user name :
</td>
<td>
<input type="text" name="user" size="20">

</td>
</tr>

<tr>
<td>
<font face=verdana><b> Enter old password :
</td>
<td>
<input type="password" name="pwd" size="20">
</td>
</tr>

<tr>
<td>
<font face=verdana><b> Enter new Password :
</td>
<td>
<input type="password" name="pwd2" size="20">
</td>
</tr>

<tr>
<td>
<font face=verdana><b> Re-enter new Password :
</td>
<td>
<input type="password" name="pwd3" size="20">
</td>
</tr>
<tr>
<th colspan="2">
<input type="submit" value=" CHANGE ">
</th>
</tr>
</table>


</form>

<script language="javascript">
document.login.user.focus();
</script>
</body>
</html>



Then now when he submits after filling the inputs thenthe page shifts to the changepass2.asp file and the code of changepass2 is as follows:

<%
Response.Buffer = True
Dim Uid,Pwd,UserType
Dim ChkUser, ChkUserRS

Uid = request.form("user")
Pwd = request.form("pwd")
Pwd2 = request.form("pwd2")
Pwd3 = request.form("pwd3")

if pwd2 <> pwd3 then
Response.Write "<html><body background='../jpgfiles/logo10poorer.jpg'>" &_
"<font face='comic sans ms' color=red> <center><h2>New Password mismatch" &_
"</h2> <Br> <h3>Please try again.</h3><br>" &_
"<br><Br><Br> <font face='comic sans ms' color=blue><a href='javascript:history.go(-1)'><h3>BACK&gt&gt</a></h3></body></html>"
Response.End
end if
on error resume next %>
<!-- #include file="include.asp"-->
<% con.begintrans

set productrs = server.CreateObject("ADODB.RECORDSET")

ChkUser = "SELECT UserID,PWD,TYPE FROM eusers WHERE upper(UserID)='" & ucase(uid) & "' AND pWD='" & pwd & "'"

set ChkUserRS = Con.Execute(ChkUser)
UserType = ucase(ChkUserRS("type"))
if err.number <> 0 then
Response.Write "<h2><center><font face='courier new' Color='red'>AN error occured while connecting to the database<br></center><br>"
Response.Write "<h2><center><font face='courier new' Color='red'><a href='mailto:hypers@hd2.dot.net.in?subject=Reporti ng an error in your website&bodyformat=0&body=The following error occured in your site:-'>Please Mail us About this Error<br></center><br></a>"
Response.Write "<a href='login.asp'><h2><center><font face='courier new' Color='red'>Click here to Continue</a>"
con.rollbacktrans
Response.end
end if


if not chkuserRS.eof then
Response.Write ucase(uid) & ucase(pwd)

if ucase(uid) = ucase(chkuserRS(0)) and ucase(pwd) = ucase(chkuserRS(1)) then
UpdateQry = "UPDATE eusers SET PWD = '" & pwd2 & "' WHERE upper(UserID)='" & ucase(uid) & "' AND upper(PWD)='" & pwd & "'"

Con.execute(UpdateQry)
con.committrans

session("user") = chkuserRS(0)
session("utype") = UserType
Con.close
set con = nothing
Response.Write usertype
if UserType = ucase("adm") or UserType = ucase("seller") then
Response.Redirect "eshop0.asp"
Response.End
elseif UserType = ucase("buyer") then
Response.Redirect "../search/lframe2.asp"
Response.End
end if
end if
end if
Con.close
set con = nothing

Response.Write usertype & "usertype"
Response.Write "<html><body background='../jpgfiles/cmp.jpg'>" &_
"<font face='comic sans ms' color=red> <center><h2>Incorrect User Name or PassWord!!!" &_
"</h2> <Br> <h3>Please try again.</h3><br>" &_
"<br><Br><Br> <font face='comic sans ms' color=blue><a href='javascript:history.go(-1)'><h3>BACK&gt&gt</a></h3></body></html>"

%>



please check this code or else if u have any code plss sent it to me .. please do reply me
thanking you
sincerely
roshina
Mar 5 '07 #1
1 7267
jhardman
3,406 Expert 2GB
the code of changepass2 is as follows:

<%
Response.Buffer = True
Dim Uid,Pwd,UserType
Dim ChkUser, ChkUserRS

Uid = request.form("user")
Pwd = request.form("pwd")
Pwd2 = request.form("pwd2")
Pwd3 = request.form("pwd3")

if pwd2 <> pwd3 then
Response.Write "<html><body background='../jpgfiles/logo10poorer.jpg'>" &_
"<font face='comic sans ms' color=red> <center><h2>New Password mismatch" &_
"</h2> <Br> <h3>Please try again.</h3><br>" &_
"<br><Br><Br> <font face='comic sans ms' color=blue><a href='javascript:history.go(-1)'><h3>BACK&gt&gt</a></h3></body></html>"
Response.End
end if
on error resume next %>
<!-- #include file="include.asp"-->
<% con.begintrans

set productrs = server.CreateObject("ADODB.RECORDSET")

ChkUser = "SELECT UserID,PWD,TYPE FROM eusers WHERE upper(UserID)='" & ucase(uid) & "' AND pWD='" & pwd & "'"

set ChkUserRS = Con.Execute(ChkUser)
UserType = ucase(ChkUserRS("type"))
if err.number <> 0 then
Response.Write "<h2><center><font face='courier new' Color='red'>AN error occured while connecting to the database<br></center><br>"
Response.Write "<h2><center><font face='courier new' Color='red'><a href='mailto:hypers@hd2.dot.net.in?subject=Reporti ng an error in your website&bodyformat=0&body=The following error occured in your site:-'>Please Mail us About this Error<br></center><br></a>"
Response.Write "<a href='login.asp'><h2><center><font face='courier new' Color='red'>Click here to Continue</a>"
con.rollbacktrans
Response.end
end if


if not chkuserRS.eof then
Response.Write ucase(uid) & ucase(pwd)

if ucase(uid) = ucase(chkuserRS(0)) and ucase(pwd) = ucase(chkuserRS(1)) then
UpdateQry = "UPDATE eusers SET PWD = '" & pwd2 & "' WHERE upper(UserID)='" & ucase(uid) & "' AND upper(PWD)='" & pwd & "'"

Con.execute(UpdateQry)
con.committrans

session("user") = chkuserRS(0)
session("utype") = UserType
Con.close
set con = nothing
Response.Write usertype
if UserType = ucase("adm") or UserType = ucase("seller") then
Response.Redirect "eshop0.asp"
Response.End
elseif UserType = ucase("buyer") then
Response.Redirect "../search/lframe2.asp"
Response.End
end if
end if
end if
Con.close
set con = nothing

Response.Write usertype & "usertype"
Response.Write "<html><body background='../jpgfiles/cmp.jpg'>" &_
"<font face='comic sans ms' color=red> <center><h2>Incorrect User Name or PassWord!!!" &_
"</h2> <Br> <h3>Please try again.</h3><br>" &_
"<br><Br><Br> <font face='comic sans ms' color=blue><a href='javascript:history.go(-1)'><h3>BACK&gt&gt</a></h3></body></html>"

%>



please check this code or else if u have any code plss sent it to me .. please do reply me
thanking you
sincerely
roshina
It doesn't look like you set the "con". Is this the whole code? Maybe I missed it somewhere.

Jared
Mar 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Sylvain Audet | last post: by
14 posts views Thread by Mr.KisS | last post: by
22 posts views Thread by Bob and Sharon Hiller | last post: by
4 posts views Thread by =?Utf-8?B?QXZhRGV2?= | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.