Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

E-Mail a Form for data entry

Status
Not open for further replies.

DaveMac

Technical User
Apr 9, 2000
161
US
Is there a way to create a form and then e-mail it as an attachment. The people who receive it fill it out and send it back. Upon receiving it back you do not reenter the data but have the data from the form automatically inserted into a table? I am new to ASP or any web tools and this may be my first attempt. The tools available are Access2002, SQL Server 2000, Visual FoxPro7, or VB6.0.

Any thoughts would be greatly appreciated.
 
i wouldn't want to try to parse the info out of an e-mail, sounds to hairy. why not just send a link to an ASP form that is filled out and inserts into a db? seems much easier and quicker to implement and far less hassles with trying to dig the info out of an e-mail. this way, you define how the info is input, etc...
 
This seems like a pretty hefty first project :)

First, it would be better to send them an email with a link to the page on your web server, this way you can use standard ASP to do all of your work.

Second, if you do mail them the form it will have to be in HTML only, no ASP, because ASP has to be processed by the correct DLL before it can be viewed or you just get an ugly page full of a mixture of code and random tags that were resolved. Also when they mail the form back it would be a real pain for them to have to open a web browser to let you know. Since ASP is a server-side web language it doesn't run without a request coming in for a page, so someone would have to request the page that would read the email, to insert the data. Which brings us to reading email, wel actually, you may already see how incredibly comlpicated this will get.

Third Option, kinda like the first: Mail them an HTML form, but in the form tag specify a direct URL including domain/ip in the action so that all they need to do is submit the form and it gets submitted to your ASP page on the server.


Let's go with my first and third option.

Basically you will need your HTML form. In the case of it going on the webserver there is no need to specify a full path to the server, only the local file, In the case of the email you will want to specify a full path (or it won't work), Like so:
Code:
<html>
<body>
<!-- This would be the form tag if the page was on your server -->
Code:
<form method=&quot;POST&quot; action=&quot;resolveForm.asp&quot;>
<!-- Form tag for emailed form -->
Code:
<form method=&quot;POST&quot; action=&quot;[URL unfurl="true"]http://www.myServer.com/resolveForm.asp&quot;>[/URL]
<!-- Note: You could use the second form tag in either case, the reason it's generally frowned on, however, is that if you ever move the page, or try to put the pages on a new server, you will need to change the address in all of you form tags to point at the correct server/folder whereas the first tag always points at the same directory they are viewing the file from. -->
Code:
<!-- Sample Inputs -->
Code:
Your Name:<input type=&quot;text&quot; name=&quot;txtName&quot;><br>
Your Phone:<input type=&quot;text&quot; name=&quot;txtPhone&quot; maxlength=&quot;13&quot;><br>
<input type=&quot;submit&quot; value=&quot;Submit The Form&quot;>
</form>
</body>
</html>

Ok so we have our form set up and ready to go, obviously we are only using one form tag instead of the two in the above code, having commente out the unnecessary one (pretend, ok? :) )

Now we need an ASP page to accept the form data and do something with it...
Code:
<%
Option Explicit
' Means we have to declare all variables in this script
Code:
' Lets declare some variables for name and phone
Code:
Dim userName, userPhone
' Now we read the values from the previous page into our variables
Code:
userName = Request.Form(&quot;txtName&quot;)
userPhone = Request.Form(&quot;txtPhone&quot;)
' ***** Write them to the screen just to be nice
Code:
' escape the ASP block
Code:
%>
<html>
<body>
<%
' There are two ways to do this, but luckily we have two variables so can try both ways
Code:
' The first way is to write the html and variable and text from ASP using a Response.Write
Code:
Response.Write &quot;Thank You &quot; & userName & &quot;, your submission is being processed.<br>&quot;
%>
<!-- The second way is to write the html, but only insert the value of the ASP variable in the middle, like so: -->
Code:
<u>Your Phone Number: </u> <%=userPhone%> <br>

</body>
</html>

Now while I didn't actually handle the database work, you now have a form that can be emailed or set up on your webserver (depending on which form tag you use) that sends the data to this second page we just finished. The data is pulled into variables and all that is left is putting in into the db, for which there is a FAQ and lots of other resources. Hopefully this will get you startd.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Thanks so much for the input! My company does have a network that would allow me to do what I would normally do which is Create an Access DB with a form for the Data entry. I am just using this project to start some web work. I would have a SQL DB located on a server at corp. Then crate an ASP that is a form that is the UI for the table. Items that I wanted to address by e-mailing the form was make the office managers ,17 of them, either fill out the data or select a office closed button. If they do not then I would generate a office not reported report and capture who is not filling out the form. So going back to the original question e-mailing it is not necessary. That is if the best way to go is have a DB on the server and ASP UI. Any suggestions for web sites with sample code and maybe a list of commands? I see in the code above there will be some similarities with VB and the use of variables. I learn best with samples. Thanks so much for the advice!



Yea, but I am under Budget!
 
As far as references there is aspin.com, w3schools.com (my personal favorite), asp101.com, and on and on :)

There is also some sample code on onpnt's web site: - examples with posting to a message board, but the db work will be the same
snowboardr's website: - examples using MySQL but most of the code will be exactly the same
My unreleased website: (Resources link at bottom, Resource Listing at top, go to Form Processing link for tutorial, warning most of these haven't been posted yet)

and on and on :)

There are also FAQs located by clicking the FAQ button on the top of the screen.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top