Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Pulling data from Access database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Pulling data from Access database

 Post Reply Post Reply
Author
vicky_c View Drop Down
Newbie
Newbie


Joined: 14 March 2003
Location: Scotland
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote vicky_c Quote  Post ReplyReply Direct Link To This Post Topic: Pulling data from Access database
    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 = "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    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



Edited by vicky_c
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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 this site

Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
vicky_c View Drop Down
Newbie
Newbie


Joined: 14 March 2003
Location: Scotland
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote vicky_c Quote  Post ReplyReply Direct Link To This Post Posted: 17 April 2003 at 5:43pm

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

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

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.