seanrigby
02-19-2003, 04:12 AM
Could someone help me understand this script. I am trying to make a script for a user who forgets their password to enter their email address and have one sent to them. I have the script as follows.....
<%@Language=VBScript%>
<%Response.Buffer=True%>
<html>
<body>
<%
'grab the value entered in the form, if no value was entered then show the form
email = Trim(Request.Form("email"))
If Len(email) < 1 Then
%>
<center><font color="blue">Forget your password?</font><p>
<table>
<form method="post">
<tr><td><center>Please Enter Your <b>Email Address</b></center></td></tr>
<tr><td><center><input type="text" name="email"></center></td></tr>
<tr><td><center><input type="submit" value="Submit"></center></td></tr>
</table>
</form>
</center>
<%
'otherwise, query the database and grab the password associated with the value entered in the form
Else
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=127.0.0.1;Database=plat;Uid=plat;Pwd=plat;"
sql = "SELECT Emailaddy, Passwrd FROM Customers WHERE Emailaddy = '"&email&"'"
Set RS = Conn.Execute(sql)
'if the value does not match any record in the database then tell the user
If RS.EOF Then
Response.write "<p><br><br><br><center>Invalid Email Address!</center>"
'otherwise, a match is found
Else
'grab the password from the database
password = RS("password")
'call the SendPW subroutine passing the email address and the password as arguments
Call SendPW(email, password)
Response.Write "<p><br><br><br><center>Your Password has been sent!</center>"
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
End If
End If
'here is the subroutine that actually sends the email using CDONTS.
Sub SendPW(email, password)
Set cdoMail = Server.CreateObject("CDONTS.NewMail")
cdoMail.From = "webmaster@yourdomain.com"
cdoMail.To = email
cdoMail.Subject = "Your requested password."
cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf _
& "*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"
cdoMail.Send
Set cdoMail = Nothing
End Sub
%>
</body>
</html>
I made a database, but don't know how to tell this script to check my database for the email address and so on.
Thanks a bunch,
Sean
<%@Language=VBScript%>
<%Response.Buffer=True%>
<html>
<body>
<%
'grab the value entered in the form, if no value was entered then show the form
email = Trim(Request.Form("email"))
If Len(email) < 1 Then
%>
<center><font color="blue">Forget your password?</font><p>
<table>
<form method="post">
<tr><td><center>Please Enter Your <b>Email Address</b></center></td></tr>
<tr><td><center><input type="text" name="email"></center></td></tr>
<tr><td><center><input type="submit" value="Submit"></center></td></tr>
</table>
</form>
</center>
<%
'otherwise, query the database and grab the password associated with the value entered in the form
Else
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=127.0.0.1;Database=plat;Uid=plat;Pwd=plat;"
sql = "SELECT Emailaddy, Passwrd FROM Customers WHERE Emailaddy = '"&email&"'"
Set RS = Conn.Execute(sql)
'if the value does not match any record in the database then tell the user
If RS.EOF Then
Response.write "<p><br><br><br><center>Invalid Email Address!</center>"
'otherwise, a match is found
Else
'grab the password from the database
password = RS("password")
'call the SendPW subroutine passing the email address and the password as arguments
Call SendPW(email, password)
Response.Write "<p><br><br><br><center>Your Password has been sent!</center>"
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
End If
End If
'here is the subroutine that actually sends the email using CDONTS.
Sub SendPW(email, password)
Set cdoMail = Server.CreateObject("CDONTS.NewMail")
cdoMail.From = "webmaster@yourdomain.com"
cdoMail.To = email
cdoMail.Subject = "Your requested password."
cdoMail.Body = password & vbcrlf & vbcrlf & vbcrlf _
& "*** THIS MESSAGE HAS BEEN AUTOMATICALLY GENERATED ***"
cdoMail.Send
Set cdoMail = Nothing
End Sub
%>
</body>
</html>
I made a database, but don't know how to tell this script to check my database for the email address and so on.
Thanks a bunch,
Sean