|
| |
|
|
nettop
Posts: 207 Joined: 2/9/2004 Status: offline
|
Submit Data to Database and Send Email Confirmation - 4/29/2008 0:02:41
I've seen the various posts for how to do this, but I am unable to get this default.asp page to work to submit 1 field of data to the database AND send a confirmation email. Here's the appropriate HTML: <%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.
On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Session.LCID = 1033
Err.Clear
strErrorUrl = ""
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear
Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"
Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"
fp_conn.Open Application("email_newsletter_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"
fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"
fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(1)
Dim arFormDBFields0(1)
Dim arFormValues0(1)
arFormFields0(0) = "Email_newsletter"
arFormDBFields0(0) = "Email_newsletter"
arFormValues0(0) = Request("Email_newsletter")
FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"), "Browser_type"
End If
If Request.ServerVariables("REMOTE_HOST") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"), "Remote_computer_name"
End If
FP_SaveFieldToDB fp_rs, Now, "Timestamp"
If Request.ServerVariables("REMOTE_USER") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_USER"), "User_name"
End If
fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"
fp_rs.Close
fp_conn.Close
Set oMail = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
iConf.Fields.Update
Set oMail.Configuration = iConf
oMail.To = "info@foothillbiz4sale.com"
oMail.From = "webmaster@foothillbiz4sale.com"
oMail.Subject = "Subject - NEW Newsletter Request, Page 1 completed"
oMail.TextBody = "Hey Michele: Someone has signed up to receive your newsletter from the homepage... Tim"
oMail.Send
Set iConf = Nothing
Set Flds = Nothing
Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "email_newsletter.asp"
End If
End If
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
%>
<html>
............................
<form method="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="_fpclass/fpdbform.inc"-->
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table14">
<tr>
<td>
<p align="justify">Receive the most comprehensive information about Businesses for Sale in the Grass Valley and Auburn Areas.<br>
<font color="#F4F2EB">
<span style="font-size: 4pt">
adfasdfdf</span></font></td>
</tr>
<tr>
<td>
<p align="center">
<input type="text" name="Email_newsletter" size="30" value="ENTER EMAIL ADDRESS">
<input type="submit" value="Submit" name="B3"><input type="reset" value="Reset" name="B4">
</td>
</tr>
<tr>
<td height="6"></td>
</tr>
<tr>
<td>Our team of
specialists track local businesses for
sale, sale statistics and provide
valuable articles, unavailable anywhere
else. We publish this information in our
Quarterly Newsletter. If you want to
keep ahead of market conditions, know
what is going on with businesses in the
area and receive informative articles
about business valuation and business
selling, subscribe to our newsletter -
it's free.</td>
</tr>
</table>
<input type="hidden" name="VTI-GROUP" value="0">
</form>
< Message edited by nettop -- 4/29/2008 8:34:21 >
|
|
|
|
nettop
Posts: 207 Joined: 2/9/2004 Status: offline
|
RE: Submit Data to Database and Send Email Confirmation - 4/29/2008 8:38:23
Simple Question: What is the best way to test the script? I tried to create a page with just the info below, but that didn't work (http://www.foothillbiz4sale.com/test_email.asp). Thanks for your help, Tim Set oMail = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") Set Flds = iConf.Fields iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 iConf.Fields.Update Set oMail.Configuration = iConf oMail.To = "info@foothillbiz4sale.com" oMail.From = "webmaster@foothillbiz4sale.com" oMail.Subject = "Subject - NEW Newsletter Request, Page 1 completed" oMail.TextBody = "Hey Michele: Someone has signed up to receive your newsletter from the homepage... Tim" oMail.Send Set iConf = Nothing Set Flds = Nothing
|
|
|
|
nettop
Posts: 207 Joined: 2/9/2004 Status: offline
|
RE: Submit Data to Database and Send Email Confirmation - 5/2/2008 10:38:30
I'm still trying to get this form to submit to the database AND send an email to a user to inform them that new data has been submitted. Any help would be most appreciated. Spooky suggested testing the script. I'm not exactly sure how to do that...any suggestions??? Thanks, Tim
|
|
|
|
nettop
Posts: 207 Joined: 2/9/2004 Status: offline
|
RE: Submit Data to Database and Send Email Confirmation - 5/2/2008 17:09:51
That's my problem. I'm not exactly sure 'where' to run the script to test it. I tried it in an .asp page. Is there a program to run this in? Please advise, sorry to be so lame, Tim quote:
<% On ERROR RESUME NEXT Set oMail = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") Set Flds = iConf.Fields iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 iConf.Fields.Update Set oMail.Configuration = iConf oMail.To = "info@foothillbiz4sale.com" oMail.From = "webmaster@foothillbiz4sale.com" oMail.Subject = "Subject - NEW Newsletter Request, Page 1 completed" oMail.TextBody = "Hey Michele: Someone has signed up to receive your newsletter from the homepage... Tim" oMail.Send Set iConf = Nothing Set Flds = Nothing Response.write "Error code = " & err %>
|
|
|
|
nettop
Posts: 207 Joined: 2/9/2004 Status: offline
|
RE: Submit Data to Database and Send Email Confirmation - 5/2/2008 17:25:49
I went down further in the html and at the <form> tag, I needed to replace what was there with the following and it worked fine...thanks for your patience with me...Tim: <form method="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1"> <input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"> <!--#include file="_fpclass/fpdbform.inc"-->
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|