Forums
This topic is locked
URGENT !!!! email confirmation of registering.
Posted 15 Feb 2002 21:14:13
1
has voted
15 Feb 2002 21:14:13 Serge Chabert posted:
<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>Hi guys. i have made a registering form page and i would like to send automatically to the new user a confirmation mail. i have seen the excellent tutorial on the website :
www.hiran.desilva.com/ultradev/
Unfortunately there is not cover how to send automatically a email confirmation from a local smtp server with iis (cdont). Does anybody has an idea. i include my registering form page code and my confirm registering page code below.
REGISTERING FORM PAGE :
<%@LANGUAGE="VBSCRIPT"%>
<% Session("svUsername"
<!--#include file="Connections/serge.asp" -->
<%
' *** Edit Operations: declare variables
MM_editAction = CStr(Request("URL"
If (Request.QueryString <> ""
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> ""
MM_dupKeyRedirect="registerfailure.asp"
MM_rsKeyConnection=MM_serge_STRING
MM_dupKeyUsernameValue = CStr(Request.Form("Username"
MM_dupKeySQL="SELECT Username FROM users WHERE Username='" & MM_dupKeyUsernameValue & "'"
MM_adodbRecordset="ADODB.Recordset"
set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
MM_rsKey.ActiveConnection=MM_rsKeyConnection
MM_rsKey.Source=MM_dupKeySQL
MM_rsKey.CursorType=0
MM_rsKey.CursorLocation=2
MM_rsKey.LockType=3
MM_rsKey.Open
If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
' the username was found - can not add the requested username
MM_qsChar = "?"
If (InStr(1,MM_dupKeyRedirect,"?"
MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
Response.Redirect(MM_dupKeyRedirect)
End If
MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert"
MM_editConnection = MM_serge_STRING
MM_editTable = "users"
MM_editRedirectUrl = "registersucces.asp"
MM_fieldsStr = "Firstname|value|Lastname|value|Username|value|Password|value|Email|value|Phone|value|Address|value|Zipcode|value|City|value|State|value|Country|value|Profession|value|Website|value|comments|value"
MM_columnsStr = "Firstname|',none,''|Lastname|',none,''|Username|',none,''|Password|',none,''|Email|',none,''|Phone|',none,''|Address|',none,''|Zipcode|',none,''|City|',none,''|State|',none,''|Country|',none,''|Profession|',none,''|Website|',none,''|comments|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(Request.Form(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> ""
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> ""
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
If (CStr(Request("MM_insert"
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),","
Delim = MM_typeArray(0)
If (Delim = "none"
AltVal = MM_typeArray(1)
If (AltVal = "none"
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none"
If (FormVal = ""
FormVal = EmptyVal
Else
If (AltVal <> ""
FormVal = AltVal
ElseIf (Delim = "'"
FormVal = "'" & Replace(FormVal,"'","''"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & "
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> ""
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p> </p><table width="36%" align="center">
<tr>
<td>
<form method="post" action="<%=MM_editAction%>" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Firstname:</td>
<td>
<input type="text" name="Firstname" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Lastname:</td>
<td>
<input type="text" name="Lastname" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Username:</td>
<td>
<input type="text" name="Username" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td>
<input type="password" name="Password" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td>
<input type="text" name="Email" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Phone:</td>
<td>
<input type="text" name="Phone" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address:</td>
<td>
<input type="text" name="Address" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Zipcode:</td>
<td>
<input type="text" name="Zipcode" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td>
<input type="text" name="City" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">State:</td>
<td>
<input type="text" name="State" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Country:</td>
<td>
<input type="text" name="Country" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Profession:</td>
<td>
<input type="text" name="Profession" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Website:</td>
<td>
<input type="text" name="Website" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Comments:</td>
<td>
<input type="text" name="comments" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td>
<input type="submit" value="Insert Record">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="true">
</form>
<p> </p>
</td>
</tr>
</table>
</body>
</html>
CONFIRM REGISTERING PAGE CODE :
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/serge.asp" -->
<%
Dim RssubmitConfirm__strUsername
RssubmitConfirm__strUsername = "xyz"
if (Session("svUsername"
%>
<%
set RssubmitConfirm = Server.CreateObject("ADODB.Recordset"
RssubmitConfirm.ActiveConnection = MM_serge_STRING
RssubmitConfirm.Source = "SELECT * FROM users WHERE Username = '" + Replace(RssubmitConfirm__strUsername, "'", "''"
RssubmitConfirm.CursorType = 0
RssubmitConfirm.CursorLocation = 2
RssubmitConfirm.LockType = 3
RssubmitConfirm.Open()
RssubmitConfirm_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Congratulation, <%=(RssubmitConfirm.Fields.Item("Firstname"
<p>Your Username is <%=(RssubmitConfirm.Fields.Item("Username"
Your Password is <%=(RssubmitConfirm.Fields.Item("Password"
<p>You are now a registered member.</p>
</body>
</html>
<%
RssubmitConfirm.Close()
%>
Needless to say that i have created all of this with Dreamweaver Ultradev 4 because i am not very much acquainted with the code.
I really need some help on this guys !!!!!
Replies
Replied 15 Feb 2002 21:36:36
15 Feb 2002 21:36:36 Viktor Farcic replied:
Insert code for sending email above redirection code. Something like:
If (MM_editRedirectUrl <> ""
Then
***** Code for sending email *****
Response.Redirect(MM_editRedirectUrl)
For sending email (assuming you're using ASP/VBScript) take a look at:
www.4guysfromrolla.com/webtech/faq/Email/faq2.shtml
Viktor Farcic
TalkZone Manager
If (MM_editRedirectUrl <> ""
***** Code for sending email *****
Response.Redirect(MM_editRedirectUrl)
For sending email (assuming you're using ASP/VBScript) take a look at:
www.4guysfromrolla.com/webtech/faq/Email/faq2.shtml
Viktor Farcic
TalkZone Manager