Forum Moderators: open

Message Too Old, No Replies

Form emails you back your password

anyone know how?

         

Blelisa

7:10 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Okay, my last post I fought through and with much help wrote my asp page with ado and vbscript to insert my users input into my access database.
This is the scenario I would like to accomplish now.
Customer goes to my registration page
They fill out all necessary fields on my form.
They click on submit
This goes to my asp page which inserts this data into my database.
The database then through I am assuming autonumber generates a password.
Then an email is automaticlly created which give the visitor their username and system created password, which they can log in with.
Does anyone know how it is done, or can point me in the right direction?
Thanks!

Blelisa

8:03 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Okay, let me answer myself.
I have conquered sending an email out of an asp page utilizing CDONTS. It works great!

Here is my question, I want to email a password out of my database.
Here is basic operation I want to happen
-Customer fills out registration form and clicks submit
-asp page processes form and enters customer data into database (already know how to do that)
-Database has a autonumber field in it so that when the customer info is added then it gives a number
-The same asp page prepares to send an email grabbing the email address off of the form (already know how to do that)
-in the body of the email there is code written that goes to the database and pulls that autonumber for that particlar customer and inserts it into the body of email(THIS IS WHAT I DONT KNOW HOW TO DO)
Any help? Thanks!

dotme

8:21 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Hi Blelisa

Glad you got things working. Feels great doesn't it? Getting the autonumber back out of Access can be a bit of a challenge. Here's what I found

[adopenstatic.com...]

Hope this helps point you in the right direction - I think the part you're looking for is:

-----------
sql = "INSERT INTO members (whatever) VALUES ('" & also_whatever & "')"
connection.Execute sql

sql = "SELECT @@Identity"
Set objRS = objConn.Execute(sql)
intID = objRS.Fields.Item(0).Value
-----------

According to the author, intID will now contain the autonumber value. I have never tried this - but I presume it works. If not, use SELECT to get the data back after you insert it. NOTE: Autonumbers in Access for such purposes should be random, not incremental to make it hard for someone to guess someone else's number. You may also need adovbs for this - a file I can help you find if needed. Good luck.

mfewtrell

9:01 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Why not generate the password on the asp page, send it with the other information on the form to the database for storage and at the same time send a reply email from the asp page to the user with the password on.

It certainly works fine that way with ASP.Net This also saves an extra trip to the database to recover the password.

Blelisa

9:03 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Go figure it does not work for me:
Here is my code, for practice I am asking it to go and retreive the username from the record I just inserted and show it on the screen:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ language="VBScript" %>
<html>
<head>
<title>first asp</title>
</head>
<body>

<%

Set connection = Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data\login2.mdb")
connection.Open

sql="INSERT INTO member (username, [password])"
sql=sql & "VALUES"
sql=sql & "('" & Request.Form("username") & "',"
sql=sql & "'" & Request.Form("password") & "')"

connection.Execute sql

sql = "SELECT @@Identity"
Set objRS = objConnection.Execute(sql)
intID = objRS.username.Item(0).Value
response.write(intID)

response.write(sql)

on error resume next
connection.Execute sql
if err<>0 then
Response.Write(Err.Description)
else
response.write("Record was updated!")
end if
connection.close
%>
</body>
</html>

HEre is the Error Message:
Microsoft VBScript runtime error '800a01a8'

Object required: ''

/get_pwd.asp, line 24

Thanks for your time

Easy_Coder

9:14 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you're executing off of an object that you did not create:
Set objRS = objConnection.Execute(sql)

try executing off of connection

Set objRS = connection.Execute(sql)

Blelisa

9:22 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Nope that didn't work either now I get error:
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'username'

/get_pwd.asp, line 25

Easy_Coder

9:31 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually it did work. You have additional errors in your code...

Easy_Coder

9:32 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's your bug...
intID = objRS.username.Item(0).Value

dotme

9:57 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



Yep I'm guessing that's the problem

intID = objRS.username.Item(0).Value

Should be

intID = objRS.Item(0).Value

I think this might assume that your autonumber is the first field in the database. If it's the third, go get Item(2), etc...

Curious if this works.

tomasz

1:31 am on Feb 17, 2005 (gmt 0)

10+ Year Member



snap sorry

Blelisa

3:38 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



Hi Guys!
Just wanted to give you an update. I appreciate everyone's help.
I took mfewtrell's advice and wrote my asp page to generate a random password, then store that password along with the other information gathered from my form into my database, and than email this password out to the customer.
Tested and all works well!

mfewtrell

10:35 pm on Feb 17, 2005 (gmt 0)

10+ Year Member



Glad to help!