.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 17th, 2000, 11:12 AM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 23
Protecting ASP with a password.

<i><b>Originally posted by : Padmaja Tallavajhala (coolpersona@hotmail.com)</b></i><br />Hi everyone there,<br /><br />I am preparing 2 asp pages that would ask for the login and password from the user and then only after<br />valid validation, the user is allowed to go past the login page. I have looked into the code which given in the<br />Demos of this web site. But I am not able to see what is the mistake that is occuring in this page. Could you give me hints as to<br />how I could go about doing this ?<br /><br />if you would like to use the database which has the tables, it is in the zipped file as pasted below.<br /><br />http://www.aspfree.com/asp/startpage.asp?id=1<br /><br />I have attached the code of the two pages below. Any help is appreciated.<br />Padmaja.<br />--------------------------------------------------------------------------------------------------------------------------------------------------<br />logintest.asp<br /><br /><br /><%@ Language=VBScript %><br /><%<br />response.buffer = true<br />On Error Resume Next<br />dim strconn<br /><br />'set up connection to the database:<br />stDataPath = server.MapPath("accessdatautilityphoneutilityphone.mdb")<br />'strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("/asp/password.mdb") <br /><br />'query to retreive data.<br />sSQL = "SELECT tblMemberInfo.ZoneName, tblPassword.Password " & _<br /> "FROM tblMemberInfo INNER JOIN tblPassword ON tblMemberInfo.MemberID = tblPassword.MemberID " & _<br /> "WHERE (((tblMemberInfo.ZoneName)='" & Session("ZoneName") & "'))"<br /><br />'create a connection to establish connection and a recordset.<br />set conn = server.createobject("ADODB.Connection")<br />set rs = server.createobject("ADODB.Recordset")<br /><br />'open the recordset using 2 formats.<br />rs.Open sSQL, conn, 2, 2<br /><br />'you'll need to change the path to meet your setup<br />'strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("/asp/password.mdb") <br />'set conn = server.createobject("ADODB.Connection")<br />'set rs = server.createobject("ADODB.Recordset")<br />'conn.open strconn<br />'rs.open "SELECT tblMemberInfo.MemberID, tblMemberInfo.ZoneName, tblPassword.Password " & _<br />' "FROM tblMemberInfo INNER JOIN tblPassword ON tblMemberInfo.MemberID = tblPassword.MemberID " & _<br />' "WHERE (((tblMemberInfo.ZoneName)='" & request("ZoneName") & "'))", conn, 2, 2<br /><br />if not rs.eof then rs.movefirst<br />if not rs.eof then<br /> if request("password") = rs("Password") then<br /> session("ZoneName") = request("ZoneName")<br /> session("Password") = request("Password")<br /> session("MemberID") = rs("MemberID")<br /> response.redirect request("page") <br /> end if<br />end if<br />rs.close<br />conn.close<br />set rs = nothing<br />set conn = nothing<br />%><br /><html><br /><br /><head><br /><title>Login Page</title><br /></head><br /><body><br /><p><b>LoginID:</b><i>Mynick</i></p><br /><p><b>Password:</b><i>password (Case Sensative)</i></p><br /><form ACTION="logintest.asp?page=<%= request("page") %>" METHOD="post"><br /><table border="0"><br /> <tr><br /> <td ALIGN="right">Login Name:</td><br /> <td><input TYPE="text" NAME="ZoneName" size="20"></td><br /> </tr><br /> <tr><br /> <td ALIGN="right">Password</td><br /> <td><input TYPE="password" NAME="password" size="20"></td><br /> </tr><br /> <tr><br /> <td ALIGN="right"></td><br /> <td><input TYPE="submit" VALUE="Login"> <input TYPE="reset" VALUE="Reset"> </td><br /> </tr><br /></table><br /></form><br /></body><br /></html><br />----------------------------------------------------------------------------------------------------------------------------------------<br /><br />password.asp<br /><br /><%@ Language = "VBScript"%><br /><%<br />response.buffer = true<br />'On Error Resume Next<br /><br />'give a variable for password page.<br />strPage = "password.asp"<br /><br />'set up connection to the database:<br />stDataPath = server.MapPath("accessdatautilityphoneutilityphone.mdb")<br />'strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("/asp/password.mdb") <br /><br />'query to retreive data.<br />sSQL = "SELECT tblMemberInfo.ZoneName, tblPassword.Password " & _<br /> "FROM tblMemberInfo INNER JOIN tblPassword ON tblMemberInfo.MemberID = tblPassword.MemberID " & _<br /> "WHERE (((tblMemberInfo.ZoneName)='" & Session("ZoneName") & "'))"<br /><br />'create a connection to establish connection and a recordset.<br />set conn = server.createobject("ADODB.Connection")<br />set rs = server.createobject("ADODB.Recordset")<br /><br />'open the recordset using 2 formats.<br />rs.Open sSQL, conn, 2, 2<br /><br />'strPage = "password.asp"<br />'set conn = server.createobject("ADODB.Connection")<br />'set rs = server.createobject("ADODB.Recordset")<br />'conn.open strconn<br />'rs.open "SELECT tblMemberInfo.ZoneName, tblPassword.Password " & _<br />' "FROM tblMemberInfo INNER JOIN tblPassword ON tblMemberInfo.MemberID = tblPassword.MemberID " & _<br />' "WHERE (((tblMemberInfo.ZoneName)='" & Session("ZoneName") & "'))", conn, 2, 2<br /><br />if not rs.eof then rs.movefirst<br />if rs.eof then<br /> response.redirect "logintest.asp?page=" & strPage<br />else<br /> if session("password") <> rs("password") then<br /> response.redirect "login.asp?page=" & strPage<br /> end if<br />end if<br />rs.close<br />conn.close<br />set rs = nothing<br />set conn = nothing<br />%><br /><br /><html><br /><br /><head><br /><title>Template Page</title><br /></head><br /><body><br /><p>You've logged in successful</p><br /></body><br /></html><br /><br />If you know of any other example that is better to understand, then I would appreciate it if you could<br />provide me the link to that site.<br /><br />Thanks<br /><br />

Reply With Quote
  #2  
Old August 17th, 2000, 12:50 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 23
<i><b>Originally posted by : Cander</b></i><br /><br />do this. when the user is logged on, store a session variable:<br /><br />session("logged_on") = true<br /><br />on any other pages, just do a check:<br /><br />if session("logged_on") = false then<br />'send them back to the logon page to logon<br />response.redirect("logonpage.asp")<br />end if<br /><br />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Protecting ASP with a password.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek