Print Page | Close Window

Pulling data from Access database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1830
Printed Date: 28 March 2026 at 4:07am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Pulling data from Access database
Posted By: vicky_c
Subject: Pulling data from Access database
Date Posted: 15 April 2003 at 8:43am

Hi,

I have a member area on my website and recently someone forgot their username and password.....because of this I'm now trying to write a script that allows someone to enter their e-mail address and have their username and password e-mailed to them. 

Below is what I have so far but how do I pull the username and password values from the database?

 

_________________________________________________

<%

 'Save the e-mail address from the form

 email = Request.Form ("email")

 if email = "" then Response.Redirect("empty.asp")

 CheckMail(Email)

 Function CheckMail(Email)
 Dim objRegExp , blnValid
 Set objRegExp = New RegExp
 objRegExp.Pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
 blnValid = objRegExp.Test(Email)
 If NOT blnValid THEN Response.Redirect "invalid.asp"
 End Function
 
 'Build connection with database
 set conn = server.CreateObject ("ADODB.Connection")  
 conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*************"
 set rs = server.CreateObject ("ADODB.Recordset")  
 rs.Open "SELECT * FROM admin where email='"& email &"'", conn, 1
 
 
 'If there is no record with the entered email, close connection
 'and go back to login with QueryString
 If rs.recordcount = 0 then
  rs.close
  conn.close
  set rs=nothing
  set conn=nothing
  Response.Redirect("email_not_found.asp")
 end if
 
 _________________________________________________________

What do I do here?

Here's the next bit:
__________________________________________________________


 dim objMail
 
 ' -- email variables --
 objMail.To = Trim(email)
 objMail.From = " mailto:webmistress@zoebirkett.net - webmistress@zoebirkett.net "
 objMail.Subject = "ZBAS Registration Details"
 objMail.BodyFormat = "0" ' HTML format
 objMail.Body = "Hello " & Trim(fullname) & "!" & vbCrLf & vbCrLf & "Here are your details you requested.  Please keep these safe!" & vbCrLf & vbCrLf & "Username:  " & Trim(username) & vbCrLf & "Password:  " & Trim(password1) & vbCrLf & vbCrLf & "Love Vicky :-) xxx" & vbCrLf & vbCrLf & "webmistress    http://www.zoebirkett.net - www.zoebirkett.net " & vbCrLf & vbCrLf & "The Zoe Birkett Appreciation Society!"
 
 ' -- send the email --     
 objMail.Send

' -- clean up object
Set objMail = Nothing

Response.Redirect("emailed.asp")

%>

_________________________________________________________

I would really really appreciate any help anyone can give me as this is actually part of a project I'm doing thats due in tomorrow (eeek!)

Thanks for reading!!

Loadsa love,
Vicky  xxx




Replies:
Posted By: MorningZ
Date Posted: 15 April 2003 at 10:10am
You reference three variables in the email block, but never assign them.....

If rs.recordcount = 0 then
    rs.close
    conn.close
    set rs=nothing
    set conn=nothing
    Response.Redirect("email_not_found.asp")
Else
    fullname = rs("fullname")
    username = rs("username")
    password1 = rs("password1")

end if


Also, you always always always want to check strings entered against your database

someone could cause damage/trouble since you allow them to freely enter text

protect yourself like so:
rs.Open "SELECT * FROM admin where email='"& email &"'", conn, 1

to
rs.Open "SELECT * FROM admin where email='"& Replace(email,"'","''") &"'", conn, 1

read more about this at http://www.4guysfromrolla.com/aspfaqs/ShowFAQ.asp?FAQID=194 - this site

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Mart
Date Posted: 17 April 2003 at 9:05am

Just a little tip: you just posted the path to your login database delete that line in your post and rename your database - anyone could download it and have instant access to all accounts on your login area.

 

Martin.



Posted By: Bunce
Date Posted: 17 April 2003 at 4:53pm

You should us the PM facility to inform users of this.

You've just made everyone who ready you post aware of this issue.



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: vicky_c
Date Posted: 17 April 2003 at 5:43pm

omg im so sorry!!  I feel soooooo stupid!!!!!!!!!!

Thanks for letting me know!!!!!!!!!!!!!!!!!!!

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net