Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 24th, 2004, 09:35 AM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validating a form field against a database

I retrieve a password from my database and set Session("Password").

Later, in my OnClick event, I try to compare the password that the user enetered on the form to Session("Password"). I get "Error on Page". I know Session("Password") contains the correct value because I display it BEFORE the onlick event is called. But it is not accessible from within the OnClick event. Is my timing off? How do I do this???

Thanks in advance!
Dave

Sub btnSubmit_OnClick()
  ' Check for password change
  If Len(frmAdd.Password.value) > 0 then
    If (frmAdd.Password.value <> Session("Password")) then
      Alert("The password that you entered does not match our files. Please correct.")
      frmAdd.Password.focus
      Exit Sub
    End if
End Sub


Reply With Quote
  #2 (permalink)  
Old April 24th, 2004, 10:20 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're mixing client side and server side code. Sessions live on the server, while the OnClick will fire in the browser. To do what you want to do, either submit the page to the server and compare there, or send the value of the Session variable to the client, like this:

If (frmAdd.Password.value <> '<%=Session("Password")%>') then

IMO, storing passwords in client side code is not really a good and secure idea, so maybe you're better off posting to the server.....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


Reply With Quote
  #3 (permalink)  
Old April 24th, 2004, 04:07 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you so much for your help. It straightend my thinking out. You will never know how much I appreciate this kind of assistance from you and people like yourself!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compare form field to database before submit chelle60 Javascript How-To 3 January 2nd, 2007 05:42 AM
Validating textbox in field level Paula222 Access VBA 5 February 15th, 2006 11:57 AM
Adding multiple form field values to database cdenequolo Classic ASP Basics 1 August 17th, 2004 05:38 PM
Validating a hidden field mkerchenski ASP.NET 1.0 and 1.1 Basics 1 June 3rd, 2004 11:20 AM
validating rich text field for attachment Mimi Javascript How-To 4 August 25th, 2003 03:12 AM



All times are GMT -4. The time now is 01:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.