Current location: Hot Scripts Forums » Programming Languages » ASP » Form to database to email

Form to database to email

Reply
  #1 (permalink)  
Old
New Member
 
Join Date: Nov 2003
Location: United Kingdom
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Form to database to email

Hi All,

I have recently found a form script that will submit data to an access database and then send the data by email to a designated email address and the administrator (see below). Its pretty damned good but it just doesn't do enough for my purposes.

What I desperately need is to be able to...

Submit data to a database and send an email which would contain the submitted data plus a hypertext link based on the database record just created. This would/should enable the email recipient to click on the link to open a new web page containing more submission fields and so on.

Sounds complicated but I'm sure there must be a way. If you know of any
way to make this posible I would be grateful for any useful suggestions.

I found the script and database at http://cybercoded.com/Downloads/RFI-Download.asp

<html>
<head>
<meta name="GENERATOR" Content="Microsoft FrontPage 5.0">
<title>Input Form</title>
</head>
<body>
<%
if request.form("Submit")<> "Submit" then
%>
<form action="rfi.asp" method="POST">
<table width="483">
<tr>
<td align="right" width="104">Type of Input</td>
<td width="369"> <select size="1" name="Type" tabindex="1">
<option value="Comment" selected>Comment</option>
<option value="Suggestion">Suggestion</option>
<option value="Question">Question</option>
</select></td>
</tr>
<tr>
<td align="right" width="104">Area</td>
<td width="369"> <select size="1" name="Area" tabindex="2">
<option value="Advertising" selected>Advertising</option>
<option value="Programs">Programs</option>
<option value="Sales">Sales</option>
<option value="Support">Support</option>
<option value="Web Site">Web Site</option>
</select></td>
</tr>
<tr>
<td align="right" width="104">First Name</td>
<td width="369">
<input name="FirstName" type="text" size="20" tabindex="3"></td>
</tr>
<tr>
<td align="right" width="104">Last Name</td>
<td width="369">
<input name="LastName" type="text" size="20" tabindex="4"></td>
</tr>
<tr>
<td align="right" width="104">email address</td>
<td width="369">
<input name="email" type="text" size="50" tabindex="5"></td>
</tr>
<tr>
<td align="right" valign="top" width="104">Comments</td>
<td width="369">
<textarea rows="5" name="Comments" cols="42" tabindex="7"></textarea></td>
</tr>
<tr>
<td align="right" width="104"><input name="Submit" type=submit value="Submit"></td>
<td width="369"><input name="reset" type=reset value="Reset"></td>
</tr>
</table>
</form>
<%
else

strType=Request.form("Type")
strArea=Request.form("Area")
strFirstName=Request.form("FirstName")
strLastName=Request.form("LastName")
stremail=Request.form("email")
strDate=Date
strID=ID
strComments=Request.form("Comments")

Set objConn = Server.CreateObject("ADODB.Connection")
ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("comments.mdb")
objConn.Open ConnectionString

sqlQuery = "SELECT * FROM Comments"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open sqlQuery, objConn, 1, 2

objRS.AddNew
objRS("Type")=strType
objRS("Area")=strArea
objRS("FirstName")=strFirstName
objRS("LastName")=strLastName
objRS("email")=stremail
objRS("SubmitDate")=strDate
objRS("comments")=strcomments

objRS.Update
objRS.Close
Set objRS = Nothing
strBody = "ID ------> " & strID & chr(10) & chr(13)
strBody = "Type ------> " & strType & chr(10) & chr(13)
strBody=strBody & "Area ------> " & strArea & chr(10) & chr(13)
strBody=strBody & "Name ------> " & strFirstName & " " & strLastName & chr(10) & chr(13)
strBody=strBody & "email -----> " & stremail & chr(10) & chr(13)
strBody=strBody & "Comments --> " & strComments & chr(10) & chr(13)
strBody=strBody & "Date ------> " & strDate & chr(10) & chr(13)
strBody=strBody & "--------------- " & chr(10) & chr(13)

Dim objCDO

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

objCDO.From = "you@yoursite.co.uk"
objCDO.To = "you@yoursite.co.uk"
objCDO.Subject = "Feedback Form"
objCDO.Body = strBody
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

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

objCDO.From = "you@yoursite.co.uk"
objCDO.To = stremail
objCDO.Subject = "Feedback Form"
objCDO.Body = strBody
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send

Response.Write "Record Added Succesfully<BR><BR>"
Response.Write strFirstName & " " & strLastName
Response.Write ", Thanks for the " & strType
Response.Write " about our " & strArea



end if
%>

</body>
</html>
Reply With Quote

Featured Marketplace Scripts (view more)

Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM
Preventing email form abuse LunarOrbit Perl 3 10-04-03 09:55 PM
send email when sending form (asp) bmatth1 Script Requests 0 09-30-03 05:52 AM
How can I do a confirmation email for a database? ashur PHP 1 08-22-03 07:32 AM
How can I do a confirmation email for a database? ashur ASP 2 08-05-03 09:42 PM


All times are GMT -5. The time now is 04:37 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.