Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Mailing form resultsand updating a dbase
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Mailing form resultsand updating a dbase

 Post Reply Post Reply
Author
johnnie View Drop Down
Newbie
Newbie


Joined: 29 July 2003
Location: Ghana
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote johnnie Quote  Post ReplyReply Direct Link To This Post Topic: Mailing form resultsand updating a dbase
    Posted: 12 August 2003 at 12:19pm
Any script that does the following........mailing web form results and at the same time, updating a SQL database
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 12 August 2003 at 12:33pm

you mean populate your database and send an e-mail at the same time?

if this is what you are looking for... itīs really easy, just mix the two codes and you will make it. Put all the info in variables, use it to update your db fields and after that (dont forget to close the db connections) you use them again to fill your e-mail fields.

Back to Top
johnnie View Drop Down
Newbie
Newbie


Joined: 29 July 2003
Location: Ghana
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote johnnie Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2003 at 7:58am
Great faubo....but please can't i get any sample code to compare it to my situation?
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 13 August 2003 at 6:47pm

Johnnie,

I will give you some sample code. But this is for an Access database. It should not be hard to modify the code to work with SQL Server Database. I hope this helps.

Here's some sample code:

'Declare constants for a recordset that allows adding records

Const adLockOptimistic = 3

Const adOpenDynamic = 2

dim sqlString

dim connectionString, databaseName, Path

'Set connection details (add your connection details here)

'Set the sqlString (add your sql statement here)

'Create the recordset

set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic

dim FirstName, LastName, Name

'Get values for new record from the form that the user submitted on the previous web page 

FirstName = Request.Form("txtFirstName")

LastName = Request.Form("txtLastName")

Name = firstName & " " & lastName

rs.AddNew

rs("FirstName") = FirstName

rs("LastName") = LastName

'Fill in recordset field values, while converting all

'empty strings to Null values

rs("FirstName") = ConvertEmptyToNull(FirstName)

rs("LastName") = ConvertEmptyToNull(LastName)

'Save the record to the database for the first recordset

rs.Update

 

dim MyMail

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

EmailBody = "Name: " & Name & ""

MyMail.From = Name & "<" & Email & ">"

MyMail.To = "info@youremailaddress.com"

MyMail.Subject = "Hello"

MyMail.Body = EmailBody

MyMail.Send

set MyMail = Nothing

rs.Close 

Set rs = Nothing

Back to Top
johnnie View Drop Down
Newbie
Newbie


Joined: 29 July 2003
Location: Ghana
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote johnnie Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2003 at 1:37am
thanx Misty.....will give it a try......and get in touch
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.