473,372 Members | 904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 7404
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

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

Similar topics

1
by: gicio | last post by:
HI! I have a little problem: I have change the administrator password (Windows 2003 Server) which MS SQL 2000 use to login. And now the SQL server can't stand up. What should I do? thx!
0
by: Sylvain Audet | last post by:
Hi there! We are experiencing a very strange problem with our VB.NET application. The application is using .NET Framework v1.1.4322 and the problem is experienced only by Windows XP users. ...
14
by: Mr.KisS | last post by:
Hi, How to change the account that ASP.NET uses for this virtual directory to one that has rights to the SQL Server box. Or how to use impersonation set in the Web.config file for the asp...
2
by: Rod | last post by:
I have a requirement in which I need to allow the user to log into our ASP.NET application, but also be able to change their Windows password, if it is expired. I had thought that Windows...
22
by: Bob and Sharon Hiller | last post by:
I have an ASP page that was done in VBScript It is setup to read an Access database and I need to change it to read a Sql 2005 Database. The code that is used to open the Access Database: Set...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
0
by: shellegreen | last post by:
Hello, I need help with some password changes that I have to do in some iPAQs. The company that I work has 3 models of iPAQ and 3 different versions of Windows Mobile (Microsoft Pocket PC...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.