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. - <%
-
' Declaring variables
-
Dim name, email, country, comments, data_source, con, sql_insert
-
-
' A Function to check if some field entered by user is empty
-
Function ChkString(string)
-
If string = "" Then string = " "
-
ChkString = Replace(string, "'", "''")
-
End Function
-
-
' Receiving values from Form
-
name = ChkString(Request.Form("name"))
-
email = ChkString(Request.Form("email"))
-
country = ChkString(Request.Form("country"))
-
comments = ChkString(Request.Form("comments"))
-
-
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
-
Server.MapPath("form.mdb")
-
sql_insert = "insert into users (name, email, country, comments) values ('" & _
-
name & "', '" & email & "', '" & country & "', '" & comments & "')"
-
-
' Creating Connection Object and opening the database
-
Set con = Server.CreateObject("ADODB.Connection")
-
con.Open data_source
-
con.Execute sql_insert
-
' Done. Close the connection
-
con.Close
-
Set con = Nothing
-
Response.Write "All records were successfully entered into the database."
-
%>
2 2519
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 - 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
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 - 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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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....
|
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
| |