|
-
Feb 23rd, 2001, 05:28 AM
#1
Thread Starter
Junior Member
Hi there i want to submit a form that the details are added to a text file.
I also want the user to be taken to a page with the details they r about to submit to confirm it, i also want the form to be copied to their email account.
Can this be done !?
Please please drop any information below, if u want me to upload the html file i am working with at the moment then i can if this would help further.
thanks
-
Feb 24th, 2001, 01:48 AM
#2
PowerPoster
Yeah, this can be easily done in a lot of languages. One question, you said CGI, do you want it to be done in Perl? Does it matter?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Feb 25th, 2001, 07:43 AM
#3
Thread Starter
Junior Member
Soupermail
Yeah I was told that i could use soupermail to do it but i am really crap at using cgi scripts.
I woudl like the user to confirm what they have added, get it sent to their inbox and then uploaded as a txt file to the server.
If you could explain further i would be very grateful
~Ben
-
Feb 26th, 2001, 08:14 AM
#4
Fanatic Member
visordown
Well, this should work:
Create a HTML page named "mySubmitPage.htm" and paste in the following:
Code:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<FORM NAME="NewMessage" ACTION="PostData.asp?action=save" METHOD="post">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD VALIGN="top" ALIGN="right">Name: </TD>
<TD><INPUT TYPE="text" NAME="name" MAXLENGTH="50" VALUE=""></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">E-mail: </TD>
<TD><INPUT TYPE="text" NAME="email" MAXLENGTH="50" VALUE=""></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 1: </TD>
<TD><INPUT TYPE="text" NAME="Item1" MAXLENGTH="50" VALUE=""></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 2: </TD>
<TD><INPUT TYPE="text" NAME="Item2" MAXLENGTH="50" VALUE=""></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 3: </TD>
<TD><INPUT TYPE="text" NAME="Item3" MAXLENGTH="50" VALUE=""></INPUT></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="right"><INPUT TYPE="reset" VALUE="Reset Form" id=reset1 name=reset1> <INPUT TYPE="submit" VALUE="Post Data" id=submit1 name=submit1></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Then create an ASP page called "PostData.asp" and paste in the following code:
Code:
<%@ Language=VBScript %>
<%
' Default Access 2000 DB connection info
' Not using a constant, as the MapPath function is used in string
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("database/MyData.mdb") & ";"
' Sample SQL Server connection info
'Const DB_CONNECTIONSTRING = "Provider=SQLOLEDB; Data Source=myServer; Initial Catalog=myDater;"
'Const DB_USERNAME = "webuser"
'Const DB_PASSWORD = "webuser"
Const SEND_EMAIL = True
' This is the From address which will send the email
' Typicaly this is an account on your exchange.server in the same PC as IIS.
Const EMAIL_SERVER_ADDR = "Keyfax Webmaster <[email protected]>"
' You'll need to modify this function to use whatever email compnent
' you prefer if you want to use email notification.
Sub SendEmail(strTo, strSubject, strBody)
' DB and email object vars for email notification
Dim objCDOMail
' Make sure emailing is enabled
If SEND_EMAIL Then
' Create an instance of the NewMail object.
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
' Set the properties of the object
objCDOMail.From = EMAIL_SERVER_ADDR
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody
' Send the message!
objCDOMail.Send
Set objCDOMail = Nothing
End If
End Sub ' SendEmail
' Open up the database and INSERT the data
Sub InsertData(sName, sItem1, sItem2, sItem3)
Dim conn
Dim sql
Set conn = Server.createobject("ADODB.CONNECTION")
conn.open DB_CONNECTIONSTRING
sql = "INSERT INTO myTable(Name, Item1, Item2, Item3) " & _
"VALUES ('" & sName & "', '" & sItem1 & "', '" & sItem2 & "', '" & sItem3 & "')"
conn.execute(sql)
Set conn=Nothing
End Sub ' InsertData
Sub DoSubmit()
Dim sSubject, sMessage, bNotify
Dim sItem1, sItem2, sItem3
Dim sName, sEmail ' User Info from Cookies
Select Case Request.QueryString("action")
Case "save"
' Retrieve parameters
sName = oConfirmation.name.Value
sEmail = oConfirmation.email.Value
'' The name and email could be fetched from a cookie as follows
' sName = Request.Cookies("name")
' sEmail = Request.Cookies("email")
'' If the data is held in a database, then query for data based
'' on a supplied userID as follows
' Dim conn, strSQL, ORS, strUserID
' strUserID = Request.Form("UserID")
' conn.open DB_CONNECTIONSTRING
' strSQL = "SELECT name, email FROM users WHERE userID = '" & strUserID & "'"
' Set ORS = conn.execute(sql)
' If Not ORS.EOF Then
' sName = ORS.Fields("name")
' sEmail = ORS.Fields("email")
' End If
'
'' There obviously needs some validation here for a password
'' This example is for reference only.
' Add all the items on the form which are to be validated and
' in turn to be included in the Email confirmation and database INSERT.
sItem1 = oConfirmation.Item1.Value
sItem2 = oConfirmation.Item2.Value
sItem3 = oConfirmation.Item3.Value
' DO YOUR VALIDATION HERE
' To keep this simple I am only checking for values in each input field.
If Len(Trim(oConfirmation.Item1.Value)) > 0 Or Len(Trim(oConfirmation.Item2.Value)) > 0 Or Len(Trim(oConfirmation.Item3.Value)) > 0 Then
sSubject = "Submission notification"
sMessage = "Item1=[" & oConfirmation.Item1.Value & "]" & vbCrLf & _
"Item2=[" & oConfirmation.Item2.Value & "]" & vbCrLf & _
"Item3=[" & oConfirmation.Item3.Value & "]"
' Send the email confirmation to the user
SendEmail sEmail, sSubject, sMessage
InsertData sName, sItem1, sItem2, sItem3
Else
End If
Case Else
End Select
End Sub
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Confirmation</TITLE>
</HEAD>
<BODY>
<FORM NAME="oConfirmation">
<P>You have requested to send the following data. Please confirm the following details are correct</P>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD VALIGN="top" ALIGN="right">Name: </TD>
<TD><INPUT TYPE="text" NAME="name" MAXLENGTH="50" VALUE="<%=Request.Form("name")%>"></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">E-mail: </TD>
<TD><INPUT TYPE="text" NAME="email" MAXLENGTH="50" VALUE="<%=Request.Form("email")%>"></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 1: </TD>
<TD><INPUT TYPE="text" NAME="Item1" MAXLENGTH="50" VALUE="<%=Request.Form("Item1")%>"></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 2: </TD>
<TD><INPUT TYPE="text" NAME="Item2" MAXLENGTH="50" VALUE="<%=Request.Form("Item2")%>"></INPUT></TD>
</TR>
<TR>
<TD VALIGN="top" ALIGN="right">Item 3: </TD>
<TD><INPUT TYPE="text" NAME="Item3" MAXLENGTH="50" VALUE="<%=Request.Form("Item3")%>"></INPUT></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="right"><INPUT TYPE="button" VALUE="Send Data" id=submit1 name=submit1 onClick="DoSubmit()"></INPUT></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
You will have to check with your server administrator about the email service running on the server and change accordingly. I have used CDONTS.
When both are in IIS, in the same folder, run "mySubmitPage".
Hope this helps
-
Feb 26th, 2001, 08:32 AM
#5
Thread Starter
Junior Member
Thankyou ever so much, It looks perfect. I will try it out, but i am not very good so i cant guarantee getting it to work, but i will keep you up to date !
Thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|