Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2003, 07:59 AM
Authorized User
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to MAMBONO
Default SPLIT FORM AND MAILING SCRIPT

I have a form which sends data to be pushed into an access database and I want the contents of the form to be emailed as well using CDONTS. I am able to d all of this in one file but I want to split the two functions between two files, one to post to the database, and another to grab the data and email it. WHat I would like to know is if it is possible to do that because my data does not seem to get to the mailing script and the email I get is blank without any data collected. I have tried to use the Response.Buffer property but it still doesn't seem to work. I'd appreciate some help with this issue please. Below is the code for both scripts. in the order that the server processes the data.

-------------------------
DATABASE UPDATE SCRIPT
-------------------------
<%

  Strname = replace(Request("name"),"'","''")
  Stremail = replace(Request("email"),"'","''")
  Strurl = replace(Request("url"),"'","''")
  Strlocation = replace(Request("location"),"'","''")
  Strcomments = replace(Request("comments"),"'","''")

  dbfile=Server.MapPath("guestbook.mdb")
  'Create a Connection Object
  Set OBJdbConnection=Server.CreateObject("ADODB.Connect ion")


  OBJdbConnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq="&dbfile
'
  sql_ins="INSERT into comment (name, email, url, location, comments) VALUES " & _
      "('" & Strname & "', '" & Stremail & "','" & Strurl & "', '" & Strlocation & "', '" & Strcomments & "') "

  Set rs1 = Server.CreateObject("ADODB.Recordset")

  rs1.Open sql_ins, OBJdbConnection, 3, 3
   Response.Redirect("mailer.asp")
%>
---------------
MAILING SCRIPT
---------------
<%
  Set objCDO = CreateObject("CDONTS.NewMail")


       'Declare variables to be used
    Dim objCDO 'CDONTS mailing object



    'Set the variables to be used for generating and sending mail
    Dim HTML
    Set objCDO = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<meta http-equiv=""Content-Type"""
    HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<meta name=""GENERATOR"""
    HTML = HTML & " content=""Microsoft Visual Studio 6.0"">"
    HTML = HTML & "<title>HTMLMail</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<p><strong>"
    HTML = HTML & "Mambono.com Guestbook Entry</strong></p>"
    HTML = HTML & "<p>"
    HTML = HTML & "Wassup " & StrName & "Thank You For Signing My Guestbook, I Appreciate your efforts and Time in Doing that.<br><br>"
    HTML = HTML & "<strong>MAMBONO </strong><br><br>"
    HTML = HTML & "<a href=http://www.mambono.com><strong>[blue]www.mambono.com </strong></a><br>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"



    'Set the mailing parameters e.g. mail to, body etc...
    objCDO.To = Stremail
    objCDO.From = "[email protected] (MAMBONO)"
    objCDO.cc = ""
    objCDO.Subject = "THANKS"
    objCDO.BodyFormat = 0
    objCDO.MailFormat = 0
    objCDO.Body = HTML

objCDO.Send

%>

<% Set objCDO = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<meta http-equiv=""Content-Type"""
    HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<meta name=""GENERATOR"""
    HTML = HTML & " content=""Microsoft Visual Studio 6.0"">"
    HTML = HTML & "<title>HTMLMail</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<p><strong>"
    HTML = HTML & "Mambono.com Guestbook Entry</strong></p>"
    HTML = HTML & "<p>"
    HTML = HTML & "A new guestbook Entry has been submitted and below are the details submitted<br>"
    HTML = HTML & "<br>"
    HTML = HTML & "<strong>Name: </strong>" & Strname & "<br>"
    HTML = HTML & "<strong>Email: </strong><a href=mailto:"& Stremail &">" & Stremail & "</a><br>"
    HTML = HTML & "<strong>URL: </strong><a href="& Strurl &">" & Strurl & "</a><br>"
    HTML = HTML & "<strong>Location: </strong>" & Strlocation & "<br>"
    HTML = HTML & "<strong>Comments: </strong>" & Strcomments & "<br>"
    HTML = HTML & "<br>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"


    Set objCDO = Server.CreateObject("CDONTS.NewMail")


    objCDO.To = "[email protected] (MAMBONO)"
    objCDO.From = "[email protected] (GUESTBOOK)"
    objCDO.cc = ""
    objCDO.Subject = "NEW GUESTBOOK ENTRY"
    objCDO.BodyFormat = 0
        objCDO.MailFormat = 0
        objCDO.Body = HTML

    objCDO.Send
    set objCDO = nothing

  Response.Redirect("view.asp")
%>

 
Old December 5th, 2003, 10:51 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you use Response.Redirect, you are basically telling the browser to go to a new URL (mailer.asp). You don't get any of the posted data or any of the variables that are on the first page because as far as the server is concerned, this is a brand new page request (using the GET method).

You could use the Server.Transfer method. This Transfers the execution of the page over to another page, while retaining the querystring and posted data. However if you do this, you'll need to have the next page (mailer.asp) also grab the values from Request, because this is essentially a new page execution.

What might be more applicable to your situation is an include. Instead of a redirect, you can actually include the other page for execution with the same script.
Change this:
    Response.Redirect("mailer.asp")
    %>
to this:
    %>


This makes mailer.asp become part of the database update script so it executes with it, but it stored in another file.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 8th, 2003, 04:55 AM
Authorized User
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to MAMBONO
Default

Thanks Planoie the Server.Transfer Method works the wonders. I'd used the include method but it was not working properly so that was why I was looking at another option.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Split form dcc15 VB Databases Basics 2 November 26th, 2007 08:36 PM
how to submit a form and post java script variable arabuafef ASP.NET 1.0 and 1.1 Basics 2 July 14th, 2006 09:28 PM
How to connecting java script form to xml file ashraf Javascript How-To 1 December 10th, 2004 05:47 AM
How to script search form in PHP/MYSQL javabeans PHP How-To 0 January 12th, 2004 03:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.