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: - 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 - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<head><title>Edit User Information</title></head>
-
<%
-
Dim oConn, oRs
-
Dim connectstr, sDSNDir, tablename
-
Dim db_name, db_username, db_userpassword
-
Dim dsn_name
-
-
dsn_name = "jerry_db.dsn"
-
tablename = "tblRegister"
-
db_username = "****"
-
db_userpassword = "****"
-
-
sDSNDir = Server.MapPath("/_dsn")
-
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
-
Dim EmailFrom
-
Dim EmailTo
-
Dim Subject
-
Dim Message
-
-
EmailFrom = "jerry@digital.com"
-
EmailTo = Trim(Request.Form("email"))
-
Subject = "Here is your Password"
-
Message = "You're password is:" & <%=objRS("Password" )%>
-
-
-
Dim validationOK
-
validationOK=true
-
If (validationOK=false) Then Response.Redirect("index.html")
-
-
Dim Body
-
Body = Body & message
-
-
-
Dim mail
-
Set mail = Server.CreateObject("CDONTS.NewMail")
-
mail.To = EmailTo
-
mail.From = EmailFrom
-
mail.Subject = Subject
-
mail.Body = Body
-
mail.Send
-
-
-
Dim objRS, bolFound, strEmail
-
strEmail = Request.Form("email")
-
-
If ((Request.Form("email") = "") Then
-
-
oConn.Close
-
Set oConn = Nothing
-
%>
-
You must enter values for all the fields. Either hit the "back" button or click <a hred="login.html"> here to log in</a>
-
<%
-
Else
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "tblRegister", oConn, , adLockOptimistic, adCmdTable
-
bolFound = False
-
-
Do Until objRS.EOF OR bolFound
-
If (StrComp(objRS("Email"), strEmail, _
-
vbTextCompare) = 0) Then
-
-
BolFound = True
-
Else
-
objRS.MoveNext
-
End If
-
Loop
-
-
If Not bolFound Then
-
objRS.Close
-
Set objRS = Nothing
-
oConn.Close
-
Set oConn = Nothing
-
Response.Write "<a href='login.html'>"
-
Response.Write "Invalid Email Address.<p>"
-
Response.Write "</a>"
-
Response.End
-
End If
-
objRS("Email") = Request.Form("email")
-
-
objRS.Update
-
objRS.Close
-
Set objRS=Nothing
-
End If
-
oConn.Close
-
Set oConn = Nothing
-
%>
-
Your password has been sent to your email account. Please click <a href="login.html">here</a> to log in to your account.
-
</body>
-
</html>
3 5558 jhardman 3,406
Recognized Expert Specialist
I have posted my code below. However, I get an error on line 31: - 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: - Message = "You're password is:" & objRS("Password" )
Let me know if this helps.
Jared
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: - <%@ Language=VBScript %>
-
<% Option Explicit %>
-
<!--#include virtual="/adovbs.inc"-->
-
<html>
-
<%
-
Dim oConn, objRS
-
Dim connectstr, sDSNDir, tablename
-
Dim db_name, db_username, db_userpassword
-
Dim dsn_name
-
-
dsn_name = "access_db.dsn"
-
tablename = "tblRegister"
-
db_username = "****"
-
db_userpassword = "****"
-
-
sDSNDir = Server.MapPath("/_dsn")
-
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
-
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
oConn.Open connectstr
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "tblRegister", oConn, , adLockOptimistic, adCmdTable
-
-
Dim EmailFrom
-
Dim EmailTo
-
Dim Subject
-
Dim Message
-
-
EmailFrom = "jerry@jerry.com"
-
EmailTo = Trim(Request.Form("email"))
-
Subject = "Your Password"
-
Message = "You're password is:" & objRS("Password" )
-
-
-
Dim validationOK
-
validationOK=true
-
If (validationOK=false) Then Response.Redirect("index.html")
-
-
Dim Body
-
Body = Body & message
-
-
Dim mail
-
Set mail = Server.CreateObject("CDONTS.NewMail")
-
mail.To = EmailTo
-
mail.From = EmailFrom
-
mail.Subject = Subject
-
mail.Body = Body
-
mail.Send
-
-
Response.Write "Your password has been emailed to you."
-
Response.Write "<a href='login.html'>"
-
Response.Write "Click here to log in to your account"
-
Response.Write "</a>"
-
-
objRS.Close
-
Set objRS = Nothing
-
oConn.Close
-
Set oConn = Nothing
-
%>
-
</body>
-
</html>
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. - Dim objRS, bolFound, strEmail
-
strEmail = Request.Form("email")
-
-
If strEmail = "" Then
-
oConn.Close
-
Set oConn = Nothing
-
Response.Write "<a href='forgot.html'>"
-
Response.Write "You must enter a email address"
-
Response.Write "</a>"
-
Response.End
-
End If
-
-
Set objRS = Server.CreateObject("ADODB.Recordset")
-
objRS.Open "tblRegister", oConn, , , adCmdTable
-
bolFound = False
-
-
Do While Not (objRS.EOF OR bolFound)
-
If (StrComp(objRS("Email"), strEmail, vbTextCompare) = 0) Then
-
BolFound = True
-
Else
-
objRS.MoveNext
-
End If
-
Loop
-
-
If Not bolFound Then
-
objRS.Close
-
Set objRS = Nothing
-
oConn.Close
-
Set oConn = Nothing
-
Response.Write "<a href='forgot.html'>"
-
Response.Write "Invalid Email Address.<p>"
-
Response.Write "</a>"
-
Response.End
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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 -...
|
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
|
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>
|
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,
| |
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 :
|
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)) {
?>
|
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.
|
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. :)
|
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,...
|
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...
| |
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |