Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

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 June 14th, 2004, 03:21 PM
kleb kleb is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 7 kleb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Asp And File System Object -- Coding

Hi there,

I have a password protected site and the database is a textfile which contains user's email address and password.
When a user forgets his password I have a popup window which asks for the user's email address and on the basis of this I want to capture the record in the text file and email it to him. I have following code:

<%@language = "VBScript" %>
<%
Dim strEmail
strEmail = Request.Form("email")

Session("user")=strEmail

set pwdObj = Server.CreateObject("Scripting.FileSystemObject")
set gtFile = pwdObj.openTextFile(Server.MapPath("register.txt"))
While not gtFile.AtEndOfStream
if gtFile.ReadLine=Session("user") Then
gtfile.close

Dim mytxt

mytxt = "Here is your password:"
mytxt = mytxt & vbcrlf & vbcrlf&_
mytxt=mytxt &gtFile.ReadLine & vbcrlf&_
mytxt = mytxt & vbcrlf & vbcrlf&_
"Please make a note of it."
mytxt = mytxt & vbcrlf&_
"Site Administrator."

Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = strEmail
ObjMail.cc = me@myself.com
Objmail.From = me@myself.com
ObjMail.Subject = "Your Password."
ObjMail.Body = mytxt
ObjMail.Send
Set ObjMail = Nothing

Response.Redirect "emailsent.asp"
Else
Response.Redirect "noemail.asp"
End If
WEND
%>

I know this is loaded with mistakes. I wonder if anyone could correct it for me. I'm just a beginner in this biz and am learning
by trial and error so any help would be greatly appreciated.

Many thanks
Kleb

Reply With Quote
  #2  
Old June 14th, 2004, 03:44 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 7 h 8 m
Reputation Power: 469
I would first suggest using a real database, as opposed to a text file to hold this information.
Your processing is limited with a text file.

Reply With Quote
  #3  
Old June 15th, 2004, 09:01 AM
kleb kleb is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 7 kleb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Asp And File System Object -- Coding

Quote:
Originally Posted by Memnoch
I would first suggest using a real database, as opposed to a text file to hold this information.
Your processing is limited with a text file.
==================
Many thanks your reply.

Yes I already have an Access Database. Thing is I want to master both technologies.

Perhaps you could just help me with the code for retrieving a line (one record) from the textfile and then how do I put it into a variable for email sending ?

For example : x = getFile.ReadLine

Or how would you do it?
Thanks again
kleb

Reply With Quote
  #4  
Old July 1st, 2004, 12:31 AM
Bullschmidt's Avatar
Bullschmidt Bullschmidt is offline
Guru
ASP Free Novice (500 - 999 posts)
 
Join Date: May 2003
Location: USA
Posts: 885 Bullschmidt User rank is Sergeant (500 - 2000 Reputation Level)Bullschmidt User rank is Sergeant (500 - 2000 Reputation Level)Bullschmidt User rank is Sergeant (500 - 2000 Reputation Level)Bullschmidt User rank is Sergeant (500 - 2000 Reputation Level)Bullschmidt User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 9 h 44 m 12 sec
Reputation Power: 23
Here are a couple of FSO links:

FileSystemObject
http://www.4guysfromrolla.com/webte...ileSystemObject

The Wonders of the File System Object by Chris Payne - 8/16/2000
http://www.15seconds.com/Issue/000816.htm

Or you can connect to a csv file (which can be opened in Excel and which an Excel file can be converted into) in good form just as you can to a regular database.

And for help connecting to a text file using the Jet OLE DB provider:
http://www.able-consulting.com/MDAC...rosoftJetTe xt

And based on the above link realize that the actual filename does NOT go in the connection string - rather it goes in the SQL statement (definitely a little tricky).
__________________
J. Paul Schmidt
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Asp And File System Object -- Coding


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT