By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,081 Members | 2,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,081 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
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.