| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 >File.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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Asp And File System Object -- Coding
Quote:
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 |
|
#4
|
||||
|
||||
|
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 |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Asp And File System Object -- Coding |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|