473,788 Members | 2,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get password sent to user with Forgot Password ASP page

67 New Member
Hi,

I am working on a forgotpassword. asp page. I would like the user to enter their email address, and click submit. Upon submit, an email will be sent to the user's email address provided with the "password" they registered with.

I have posted my code below. However, I get an error on line 31:

Expand|Select|Wrap|Line Numbers
  1. Message = "You're password is:" & <%=objRS("Password" )%>
The input name="email" on the html form that leads to this asp page.

Thanks for any input

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <!--#include virtual="/adovbs.inc"-->
  4. <html>
  5. <head><title>Edit User Information</title></head>
  6. <%
  7. Dim oConn, oRs
  8. Dim connectstr, sDSNDir, tablename
  9. Dim db_name, db_username, db_userpassword
  10. Dim dsn_name
  11.  
  12. dsn_name = "jerry_db.dsn"
  13. tablename = "tblRegister"
  14. db_username = "****"
  15. db_userpassword = "****"
  16.  
  17. sDSNDir = Server.MapPath("/_dsn")
  18. connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
  19.  
  20. Set oConn = Server.CreateObject("ADODB.Connection")
  21. oConn.Open connectstr
  22.  
  23. Dim EmailFrom
  24. Dim EmailTo
  25. Dim Subject
  26. Dim Message
  27.  
  28. EmailFrom = "jerry@digital.com"
  29. EmailTo = Trim(Request.Form("email"))
  30. Subject = "Here is your Password"
  31. Message = "You're password is:" & <%=objRS("Password" )%>
  32.  
  33.  
  34. Dim validationOK
  35. validationOK=true
  36. If (validationOK=false) Then Response.Redirect("index.html")
  37.  
  38. Dim Body
  39. Body = Body & message
  40.  
  41.  
  42. Dim mail
  43. Set mail = Server.CreateObject("CDONTS.NewMail") 
  44. mail.To = EmailTo
  45. mail.From = EmailFrom
  46. mail.Subject = Subject
  47. mail.Body = Body
  48. mail.Send 
  49.  
  50.  
  51. Dim objRS, bolFound, strEmail
  52. strEmail = Request.Form("email")
  53.  
  54. If ((Request.Form("email") = "") Then
  55.  
  56. oConn.Close
  57. Set oConn = Nothing
  58. %>
  59. You must enter values for all the fields. Either hit the "back" button or click <a hred="login.html"> here to log in</a>
  60. <%
  61. Else
  62. Set objRS = Server.CreateObject("ADODB.Recordset")
  63. objRS.Open "tblRegister", oConn, , adLockOptimistic, adCmdTable
  64. bolFound = False
  65.  
  66. Do Until objRS.EOF OR bolFound
  67. If (StrComp(objRS("Email"), strEmail, _
  68. vbTextCompare) = 0) Then
  69.  
  70. BolFound = True
  71. Else
  72. objRS.MoveNext
  73. End If
  74. Loop
  75.  
  76. If Not bolFound Then
  77. objRS.Close
  78. Set objRS = Nothing
  79. oConn.Close
  80. Set oConn = Nothing
  81. Response.Write "<a href='login.html'>"
  82. Response.Write "Invalid Email Address.<p>"
  83. Response.Write "</a>"
  84. Response.End
  85. End If
  86.     objRS("Email") = Request.Form("email")
  87.  
  88. objRS.Update
  89. objRS.Close
  90. Set objRS=Nothing
  91. End If
  92. oConn.Close
  93. Set oConn = Nothing
  94. %>
  95. Your password has been sent to your email account.  Please click <a href="login.html">here</a> to log in to your account.
  96. </body>
  97. </html>
Nov 7 '08 #1
3 5558
jhardman
3,406 Recognized Expert Specialist
I have posted my code below. However, I get an error on line 31:

Expand|Select|Wrap|Line Numbers
  1. Message = "You're password is:" & <%=objRS("Password" )%>
the code <%=%> is shorthand for "response.write " - it writes the contents to the webpage. This is not what you want, you want to append the contents to the variable "Message". Try this:
Expand|Select|Wrap|Line Numbers
  1. Message = "You're password is:" & objRS("Password" )
Let me know if this helps.

Jared
Nov 8 '08 #2
jerrydigital
67 New Member
Thank you for your input. It work to a degree.

I am able to email the password to the users but unfortunately, the email has the same password for all users.

How do I get the system to send the correct password to each user in my database?

Below is the code I am using:

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <!--#include virtual="/adovbs.inc"-->
  4. <html>
  5. <%
  6. Dim oConn, objRS
  7. Dim connectstr, sDSNDir, tablename
  8. Dim db_name, db_username, db_userpassword
  9. Dim dsn_name
  10.  
  11. dsn_name = "access_db.dsn"
  12. tablename = "tblRegister"
  13. db_username = "****"
  14. db_userpassword = "****"
  15.  
  16. sDSNDir = Server.MapPath("/_dsn")
  17. connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
  18.  
  19. Set oConn = Server.CreateObject("ADODB.Connection")
  20. oConn.Open connectstr
  21. Set objRS = Server.CreateObject("ADODB.Recordset")
  22. objRS.Open "tblRegister", oConn, , adLockOptimistic, adCmdTable
  23.  
  24. Dim EmailFrom
  25. Dim EmailTo
  26. Dim Subject
  27. Dim Message
  28.  
  29. EmailFrom = "jerry@jerry.com"
  30. EmailTo = Trim(Request.Form("email"))
  31. Subject = "Your Password"
  32. Message = "You're password is:" & objRS("Password" )
  33.  
  34.  
  35. Dim validationOK
  36. validationOK=true
  37. If (validationOK=false) Then Response.Redirect("index.html")
  38.  
  39. Dim Body
  40. Body = Body & message
  41.  
  42. Dim mail
  43. Set mail = Server.CreateObject("CDONTS.NewMail") 
  44. mail.To = EmailTo
  45. mail.From = EmailFrom
  46. mail.Subject = Subject
  47. mail.Body = Body
  48. mail.Send 
  49.  
  50. Response.Write "Your password has been emailed to you."
  51. Response.Write "<a href='login.html'>"
  52. Response.Write "Click here to log in to your account"
  53. Response.Write "</a>"
  54.  
  55. objRS.Close
  56. Set objRS = Nothing
  57. oConn.Close
  58. Set oConn = Nothing
  59. %>
  60. </body>
  61. </html>
Nov 9 '08 #3
jerrydigital
67 New Member
Well, I figured it out. I now am able to email users their forgotten passwords if they enter a valid email address. All I had to do is add the following code to my post #3 code. I deleted the dim objRS at the top and entered it will the rest of the code below after the connection was opened. I guess by validating that the email is in my database, it also matches up the proper password for the email supplied.

Expand|Select|Wrap|Line Numbers
  1. Dim objRS, bolFound, strEmail
  2. strEmail = Request.Form("email")
  3.  
  4. If strEmail = "" Then
  5. oConn.Close
  6. Set oConn = Nothing
  7. Response.Write "<a href='forgot.html'>"
  8. Response.Write "You must enter a email address"
  9. Response.Write "</a>"
  10. Response.End
  11. End If
  12.  
  13. Set objRS = Server.CreateObject("ADODB.Recordset")
  14. objRS.Open "tblRegister", oConn, , , adCmdTable
  15. bolFound = False
  16.  
  17. Do While Not (objRS.EOF OR bolFound)
  18. If (StrComp(objRS("Email"), strEmail, vbTextCompare) = 0) Then
  19. BolFound = True
  20. Else
  21. objRS.MoveNext
  22. End If
  23. Loop
  24.  
  25. If Not bolFound Then
  26. objRS.Close
  27. Set objRS = Nothing
  28. oConn.Close
  29. Set oConn = Nothing
  30. Response.Write "<a href='forgot.html'>"
  31. Response.Write "Invalid Email Address.<p>"
  32. Response.Write "</a>"
  33. Response.End
  34. End If

Thank you again for all of your help. I wouldn't have been able to get this far on my web site design without this forum. I hope you all continue to provide such valuable information for years to come.

Jerry
Nov 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1808
by: Arpan | last post by:
An ASP application retrieves records from a SQL Server database. In the first page of the application, the user has to enter a password & the columns retrieved from the DB table depends upon the password. For e.g. if the password entered is say, pwd1, then that user should be displayed the records of Column1 & Column2 only. If the password entered is say, pwd2, then that user should be displayed the records of Column1 & Column3 only. If...
4
3138
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time getting a SMTP script running. While the Drupal feedback module and the new account creation works fine in terms of sending of mails, I am having some problems with the sending of password reminder emails. warning: Cannot modify header information -...
6
2370
by: James | last post by:
Have a textbox that's in Password mode on a user creation page. Have several dropdowns that cause a PostBack out of necessity on this page. I cannot separate them. When one of these dropdowns changes, the textbox's value is lost. How do I prevent this? Thanks
5
2343
by: barry | last post by:
Below are my setting in the web.config file for forgotten passwords. I receive a completion that the password has been sent but upon looking in outlook there is no email sent to me. I have also tried 127.0.0.1 for the network host <system.net> <mailSettings> <smtp deliveryMethod="Network" from="mopliger@sbcglobal.net"> <network host="localhost" port="25" defaultCredentials="true"/> </smtp>
2
3203
by: pj | last post by:
I'm using asp.net 2.0 login controls, When a user forgets a password, they are sent an email with the new password. Two questions.... 1) how do I format the password that is being created to be only letters and numbers? Not something like "e%QtT6.Eja%XNG" 2) how do I redirect users to a change password page, next time they login with the new password sent to them via email? thanks is advance for any assitance,
1
7428
by: roshina | last post by:
Hi Iam facing a problem in my project, developing a web site for online shopping in ASP on windows XP using IIS server. All the validations are ok but the new password is not upadated in the data base and also showing a error page. the operating system we used is Windows XP, the source code is ASP, front end we used - HTML and javascript and vb script for validations. the inputs we used are : old pasword :
2
1990
by: chaos | last post by:
Hi all, i need help in this forgot password page, as the error message is show in another page cause the arrangement of the design in a mess. As i want to show the error message on the forgot password page. <?php session_start(); // Start Session session_register("session"); $email_address = $_POST; if (!isset($_POST)) { ?>
1
6095
by: groupie | last post by:
Hi, I'd like to know how to implement the "Forgot Password" feature on many websites which require a login, exactly like this ebay example: http://cgi4.ebay.com/ws/eBayISAPI.dll?UserIdRecognizerShow I've already retrieved the users password from the database - I just need to send it to the email address entered. From reading many posts, I need a server-side script and rather not use form mailto: nor use javascript on the users PC.
10
3482
matheussousuke
by: matheussousuke | last post by:
Hi, guys, I'm developing a script and it's almost done, just left two little things: Forgot password option Change password option About forgot password: The user can use as many user names under the same email adress, so the system needs a way to send the password for user email when user type the user name on field of forgot password. I'm running it under php 4, so don't worry if u see a $HTTP_POST_VARS. :)
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.