473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

post to database AND email a notification AND redirect user with ASP

daJunkCollector
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 notification is sent to a specified e-mail address. (I know this can be done in the database, but I would prefer it be contained within the ASP code for now, but cannot find anywhere on how to go about it simultaneously).

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).

So, I can find the proper way to do each of these on their own. But it escapes how I can accomplish all three actions for the same form and submit button.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.    ' Declaring variables
  3.    Dim name, email, country, comments, data_source, con, sql_insert
  4.  
  5.    ' A Function to check if some field entered by user is empty
  6.    Function ChkString(string)
  7.    If string = "" Then string = " "
  8.    ChkString = Replace(string, "'", "''")
  9.    End Function
  10.  
  11.    ' Receiving values from Form
  12.    name = ChkString(Request.Form("name"))
  13.    email = ChkString(Request.Form("email"))
  14.    country = ChkString(Request.Form("country"))
  15.    comments = ChkString(Request.Form("comments"))
  16.  
  17.    data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ 
  18.             Server.MapPath("form.mdb")
  19.    sql_insert = "insert into users (name, email, country, comments) values ('" & _
  20.             name & "', '" & email & "', '" & country & "', '" & comments & "')"
  21.  
  22.    ' Creating Connection Object and opening the database
  23.    Set con = Server.CreateObject("ADODB.Connection")
  24.    con.Open data_source
  25.    con.Execute sql_insert
  26.    ' Done. Close the connection
  27.    con.Close
  28.    Set con = Nothing
  29.    Response.Write "All records were successfully entered into the database."
  30.  %>
Aug 9 '07 #1
2 2519
jhardman
3,406 Expert 2GB
So, I can find the proper way to do each of these on their own. But it escapes how I can accomplish all three actions for the same form and submit button.
That's really not a problem. There is nothing in the code you wrote that would mean you have to end your script now. After the above code just continue writing the script to send the email, then make the "thank you/confirmation" notice at the bottom. One of the big advantages of splitting them into different pages is that especially email takes a while and some scripts will timeout if you give them too much to do. But if you are just entering data in a db, sending a single email, and displaying "Thank you for clicking the submit button" there is no reason you can't do it all on one page. If you want to do these all separately, just include some kind of
Expand|Select|Wrap|Line Numbers
  1. response.redirect "nextPage.asp"
or javascript [html]onLoad="window.location='nextPage.asp'"[/html] at the bottom, this will send the user to the next page as soon as everything above it is finished executing. This may take even longer than doing it all on one page, but gives you the opportunity to give status updates to the user (each successive page lists how much has been finished).

Jared
Aug 10 '07 #2
That's really not a problem. There is nothing in the code you wrote that would mean you have to end your script now. After the above code just continue writing the script to send the email, then make the "thank you/confirmation" notice at the bottom. One of the big advantages of splitting them into different pages is that especially email takes a while and some scripts will timeout if you give them too much to do. But if you are just entering data in a db, sending a single email, and displaying "Thank you for clicking the submit button" there is no reason you can't do it all on one page. If you want to do these all separately, just include some kind of
Expand|Select|Wrap|Line Numbers
  1. response.redirect "nextPage.asp"
or javascript [html]onLoad="window.location='nextPage.asp'"[/html] at the bottom, this will send the user to the next page as soon as everything above it is finished executing. This may take even longer than doing it all on one page, but gives you the opportunity to give status updates to the user (each successive page lists how much has been finished).

Jared
Jared,

You the man. Thanks again. I really appreciate your time.

Pete
Aug 13 '07 #3

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

Similar topics

8
by: aa | last post by:
If I have a customers database and wanted to automastically create and post an email from a local computer to each customer of the same content - can I do it in PHP? If affirmative which...
1
by: Rene Aguirre | last post by:
Hello, I'd like to make a sort of web tracking system for internal stuff at my office. But I'm having problems about how to add email notification to my script. I already tried to send email...
6
by: Raphael Gluck | last post by:
Hi, Is it possible for one to program one's pages as such that when a database table is updated over the web, via a form, that an e-mail confirmation is sent to a specified address, notifying...
2
by: AJ | last post by:
Hi, I wanted to know how can we send out email notification for the Jobs that are completed. Thanks a lot in advance.... AJ
1
by: rikerhill | last post by:
I'm looking for help with JS-Kit's Comment script. They offer a free script to add comments to any web page. It is as follows: <script src="http://js-kit.com/comments.js"></script> What I'm...
0
by: vsrprasad16 | last post by:
Hi All, I am implementing a notification form similar to outlook email notification. my application call this notification form from a dll. this dll includes a form class and this dll has some...
2
by: =?Utf-8?B?eHl6X2phdA==?= | last post by:
Hi, I'm planning to re-engineer an Email Notification Service (Windows Service) in C# using .net framework 3.5 which was previously written in c# using .net framework 1.1. In the old version,...
2
by: sindhudixit | last post by:
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...
3
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net app. When session is invalid, how to redirect user to the login page? I don't want to add the code to redirect user to the login page into every page. Thanks, -Billy
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.