473,466 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

post to database AND send values into email and redirect user

1 New Member
Hey,

I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen:

1. The form uploads to a database (the following code does this)

2. An e-mail is sent to my sales team as well as the customer, which contains the form values .

3. I want the user to then be directed automatically to another webpage, after they hit the submit button. (This page will read something like "Thank you for submitting your application).

I am able to do this on 2 seperate asp pages but when i try to do this on one asp page,its not working.

Please help me to solve this.

is it possible that once user hits submit button values of the form goes to insertintodatabase.asp and then somehow these values can move to sendemail.asp.please help me.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%>
  3.  
  4. <% 
  5. Dim thedate,Email,Customer,Contact,Phone,Fax,Address,City,State,Zip,part1,qty1,invoice1,po1,date1,serial1,problem1,part2,qty2,invoice2,po2,date2,serial2,problem2
  6. Dim part3,qty3,invoice3,po3,date3,serial3,problem3,part4,qty4,invoice4,po4,date4,serial4,problem4,terms,delivery,comments
  7. Dim sConnString, conn, sSQL, stSQL
  8. Dim MyNewRandomNum
  9. Randomize
  10. MyNewRandomNum = Int(Rnd * 10000000)+1
  11.  
  12. thedate=Request.form("thedate")
  13. Email=Request.form("Email")
  14. Customer=Request.form("Customer")
  15. Contact=Request.form("Contact")
  16. Phone=Request.form("Phone")
  17. Fax=Request.form("Fax")
  18. Address=Request.form("Address")
  19. City=Request.form("City")
  20. State=Request.form("State")
  21. Zip=Request.form("Zip")
  22. part1=Request.form("part1")
  23. qty1=Request.form("qty1")
  24. invoice1=Request.form("invoice1")
  25. po1=Request.form("po1")
  26. date1=Request.form("date1")
  27. serial1=Request.form("serial1")
  28. problem1=Request.form("problem1")
  29. part2=Request.form("part2")
  30. qty2=Request.form("qty2")
  31. invoice2=Request.form("invoice2")
  32. po2=Request.form("po2")
  33. date2=Request.form("date2")
  34. serial2=Request.form("serial2")
  35. problem2=Request.form("problem2")
  36. part3=Request.form("part3")
  37. qty3=Request.form("qty3")
  38. invoice3=Request.form("invoice3")
  39. po3=Request.form("po3")
  40. date3=Request.form("date3")
  41. serial3=Request.form("serial3")
  42. problem3=Request.form("problem3")
  43. part4=Request.form("part4")
  44. qty4=Request.form("qty4")
  45. invoice4=Request.form("invoice4")
  46. po4=Request.form("po4")
  47. date4=Request.form("date4")
  48. serial4=Request.form("serial4")
  49. problem4=Request.form("problem4")
  50. terms=Request.form("terms")
  51. delivery=Request.form("delivery")
  52. comments=Request.form("comments")
  53.  
  54. sSQL = "INSERT into rmarequest (req_no, date, email, company, contact, phone, fax, address, city, state, zip, part1, qty1, inv1, po1, inv_date1, serial1, problem1, part2, qty2, inv2, po2, inv_date2, serial2, problem2, part3, qty3, inv3, po3, inv_date3, serial3, problem3, part4, qty4, inv4, po4, inv_date4) values('" & MyNewRandomNum & "', '" & thedate & "','" & Email & "','" & Customer & "','" & Contact & "','" & Phone & "', '" & Fax & "', '" & Address & "', '" & City & "', '" & State & "','" & Zip & "', '" & part1 & "', '" & qty1 & "', '" & invoice1 & "', '" & po1 & "', '" & date1 & "', '" & serial1 & "', '" & problem1 & "', '" & part2 & "', '" & qty2 & "', '" & invoice2 & "', '" & po2 & "', '" & date2 & "', '" & serial2 & "', '" & problem2 & "', '" & part3 & "', '" & qty3 & "', '" & invoice3 & "', '" & po3 & "', '" & date3 & "', '" & serial3 & "', '" & problem3 & "', '" & part4 & "', '" & qty4 & "', '" & invoice4 & "', '" & po4 & "', '" & date4 & "')" 
  55. stSQL= "INSERT into rmarequest (serial4, problem4, terms, delivery, comments)values( '" & serial4 & "', '" & problem4 & "', '" & terms & "', '" & delivery & "', '" & Comments & "')"
  56.  
  57. Set conn = server.CreateObject("ADODB.connection")
  58. sConnString = "DRIVER=SQL Server;SERVER={};UID={}; PWD={};APP=;DATABASE={}" 
  59. conn.Open sConnString
  60. conn.execute(sSQL)
  61. conn.execute(stSQL)
  62. connection.Close
  63. Set conn = Nothing
  64. %><%
  65.  
  66. bodytext = ""
  67. bodytext = bodytext& "<HTML><HEAD><title>RMA Request Recieved@A3Net</title>"
  68. bodytext = bodytext&"<meta http-equiv=Content-Type content=text/css; charset=UTF-8>" 
  69. bodytext = bodytext&"<style fprolloverstyle>"
  70. bodytext = bodytext&"A:hover {color: #F6D271; font-weight: bold}.style6 {font-size: 10pt;font-weight: bold;}"
  71. bodytext = bodytext&".style7 {font-family: MS Sans Serif}.style8 {font-size: 10pt; font-weight: bold; font-family: MS Sans Serif; }"
  72. bodytext = bodytext&".style10 {font-family: MS Sans Serif;font-size: 1pt;color: #000066;font-weight: bold;}"
  73. bodytext = bodytext&".style13 {font-size: 10pt}.style14 {font-size: 1pt; color: #000066; font-family: MS Sans Serif;}"
  74. bodytext = bodytext&".style16 {font-family: MS Sans Serif;color: #003333;font-weight: bold;font-size: medium;}"
  75. bodytext = bodytext&".style17 {color: #336699}.style20 {font-family: Webdings; color: #DFAE0E;}"
  76. bodytext = bodytext&".style21 {font-size: 1pt}.style22 {font-size: 1pt; font-family: MS Sans Serif; }"
  77. bodytext = bodytext&".style24 {    font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;font-size: 9pt;}"
  78. bodytext = bodytext&".style25 { color: #000000;    font-size: 9px;}"
  79. bodytext = bodytext&"</style>"
  80. bodytext = bodytext&"</HEAD>"
  81. bodytext = bodytext&"<BODY BGCOLOR=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 link=#FFFFFF vlink=#FFFFFF alink=#FFFFFF>" 
  82.      bodytext = bodytext&"<span class=bodyplaingrey></span> <span class=bodyplainred></span> <span class=credit></span> "
  83.      bodytext = bodytext&"<span class=boldwhiteCopy></span> <span class=boldwhite></span> <span class=bodyplain></span> "
  84.      bodytext = bodytext&"<center>"
  85.      bodytext = bodytext&"<table border=1 cellpadding=0 cellspacing=0>"
  86. bodytext = bodytext&"<tr BGCOLOR=#cccccc><td align=center valign=middle><span class=style16>RMA Request Recieved@A3net</span></td>"
  87. bodytext = bodytext&"</tr><tr BGCOLOR=#e4e4e4><td align=center valign=middle><span class=style7>RMA Request Number:</span><span class=style24 style7 style13>&nbsp;&nbsp;"
  88.      bodytext = bodytext&MyNewRandomNum
  89.      bodytext = bodytext&"</span></td></tr><tr><td align=left valign=middle>"
  90.      bodytext = bodytext&"<table width=574 border=0 align=left cellpadding=0 cellspacing=0 bordercolor=#e2e2e2><tr>"
  91. bodytext = bodytext&"<td align=left valign=top class=style7>&nbsp;</td>"
  92. bodytext = bodytext&"<td align=left valign=top class=style6>&nbsp;</td></tr>"
  93.      bodytext = bodytext&"<tr><td align=left valign=top class=style7>&nbsp;</td>"
  94. bodytext = bodytext&"<td align=left valign=top class=style6>&nbsp;</td></tr>"
  95. bodytext = bodytext&"<tr bgcolor=#E4E4E4 height=30><td width=279 align=left valign=top class=style7><span class=style13><span class=style10>&nbsp;&nbsp;Request Date :</span></span><br><span class=style13>&nbsp;&nbsp;"
  96. bodytext = bodytext&thedate
  97.      bodytext = bodytext&"<br></span></td>"
  98. bodytext = bodytext&"<td width=288 align=left valign=top><span class=style10>&nbsp;&nbsp;Email:</span><br><span class=style24 style7 style13>&nbsp;&nbsp;"
  99.  
  100. bodytext = bodytext&"</table>"
  101.                                             bodytext = bodytext&"</td></tr><tr align=left valign=top><td colspan=2 class=style8>&nbsp;</td>"
  102.         bodytext = bodytext&"</tr><tr align=left valign=middle bgcolor=#E4E4E4><td height=30 colspan=2><span class=style10>&nbsp;&nbsp;Term of Exchange:</span><br><span class=style24 style7 style13>&nbsp;&nbsp;"
  103.                                             bodytext = bodytext&terms
  104. bodytext = bodytext&"</span></td></tr>"
  105.                                             bodytext = bodytext&"<tr align=left valign=top><td colspan=2 class=style8>&nbsp;</td></tr>"
  106.         bodytext = bodytext&"<tr align=left valign=top bgcolor=#E4E4E4 height=30><td colspan=2><span class=style10>&nbsp;&nbsp;Delivery Method:</span> <br><span class=style24 style7 style13>"
  107.         bodytext = bodytext&"&nbsp;&nbsp;"
  108.                                              bodytext = bodytext&delivery
  109.                                              bodytext = bodytext&"</span></td></tr><tr align=left valign=top><td colspan=2 class=style8>&nbsp;</td>"
  110.         bodytext = bodytext&"</tr><tr align=left valign=top bgcolor=#E4E4E4 height=20>"
  111.         bodytext = bodytext&"<td colspan=2><span class=style10>&nbsp;&nbsp;Explain Problem:</span><br>"
  112.          bodytext = bodytext&"&nbsp;&nbsp;<span class=style24 style7 style13>"
  113.                                             bodytext = bodytext&comments
  114.                                             bodytext = bodytext&"</span></td></tr><tr align=left valign=top><td colspan=2 class=style8>&nbsp;</td>"
  115.         bodytext = bodytext&"</tr><tr align=left valign=top><td colspan=2 class=style8>&nbsp;&nbsp;</td></tr></table>"
  116.                                              bodytext = bodytext&"</td></tr></table>"
  117.                                              bodytext = bodytext&"</center>"                                                                     
  118. bodytext = bodytext&"</BODY>" 
  119. bodytext = bodytext&"</HTML>"
  120.  
  121.  
  122. Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
  123.     Mailer.FromAddress = "sales@a3net.com"
  124.     Mailer.Cc = Email
  125.     Mailer.RemoteHost = "scriptmail.intermedia.net"
  126.     Mailer.AddRecipient "A3Net Servers Inc","rma@a3net.com"
  127.     Mailer.Subject = "A3net RMA Request("&MyNewRandomNum&")"
  128.     Mailer.ContentType = "text/html"
  129.     Mailer.BodyText = bodytext
  130.  
  131. if Mailer.SendMail then    'Message sent sucessfully
  132.     Response.Redirect "rmarequestsuccess.asp"
  133. else
  134.     Response.Redirect "rmarequestfailure.asp"
  135. end if
  136. %>
  137.  
  138. <%>
  139.  
Jul 15 '08 #1
2 2284
DrBunchman
979 Recognized Expert Contributor
Hi sindhudixit,

Welcome to Bytes.com! I hope you find the site useful.

What do you mean by "it's not working" when you try to do it all on one page? Is it throwing an error or are you not seeing the results you expect?

There's no reason why you can't do this all on one page but you could equally do it on two by passing the form values through the QueryString when you do a response.redirect.

Dr B
Jul 15 '08 #2
jhardman
3,406 Recognized Expert Specialist
There's no reason why you can't do this all on one page but you could equally do it on two by passing the form values through the QueryString when you do a response.redirect
or you could put them all in session variables (I keep saying to do this, but the truth is, I am more likely to use DrBunchman's method)
Expand|Select|Wrap|Line Numbers
  1. for each x in request.form
  2.    session(x) = request.form(x)
  3. next
Jared
Jul 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
6
by: Pete Mahoney | last post by:
I am trying to 'POST' values from a form in a ASP file that has anonymous access permissions. I can retrieve the form values when I redirect to this page from another page which has also has...
1
by: Kenshin | last post by:
Hey! I have another script where i pull all the information from the database and I want to send it to the person. What they do is they enter in their email, and if the email matches, than it will...
6
by: brian_mckracken | last post by:
This might not be the right group for this question, since its kind of a pure html question... Given the html construct: <form action='index.php?expand=0,10000' method='post'> Email: <input...
3
by: William | last post by:
Hi I have an ASP.NET application that connects to an Access database. Everything works fine except for the Session object. Data in the session object is lost after I've made a call to the...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
7
by: Carl | last post by:
these are three files below : submit.html <html> <head> </head> <body> <form action="redirect.php" method="POST" > <input type="text" name="value" value="test" > <input type="submit" >...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.