Results 1 to 9 of 9

Thread: send form script

  1. #1
    Join Date
    Dec 2001
    Location
    Labuan
    Posts
    83
    Rep Power
    219

    send form script

    I have design a survey form at http://www25.brinkster.com/alvinhan/form.asp and i wish to have the survey result to send to my email address after clicking submit button. How can i make it? I prefer not to use the mailto in the form action because it always pop up a warning box that may scare away the respondents. Please help.
    aLvinHan of ViNSiGN Web Design in Labuan and PJ

  2. #2
    Join Date
    Mar 2002
    Posts
    13
    Rep Power
    0
    i hope this will help. first you have to get the values from the form into variables. then, put these variables in the variable called HTML. variable HTML is the Body of the mail.

    good luck!


    <%
    Dim myMail, HTML

    Dim strName, strCompany, strAge, strWorkLocation, strEmail
    strName = request.form("name")
    strCompany = request.form("company")
    strAge = request.form("age")
    strWorkLocation = request.form("worklocation")
    strEmail = request.form("email")

    'this is a comment: continue like that

    Set myMail = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<p><b>Survey answers:</b></p>"
    HTML = HTML & "<p><b>Name:</b> " &strName& "<br>"
    HTML = HTML & "<b>Company:</b> " &strCompany& "<br>"
    HTML = HTML & "<b>Age:</b> " &strAge& "<br>"
    HTML = HTML & "<b>Work Location:</b> " &strWorkLocation& "<br>"

    'commment: continue like this till you put all your answers

    myMail.From=strEmail
    myMail.To="your email address come here"
    myMail.Subject="Survey Answers"
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set myMail=nothing
    %>

  3. #3
    Join Date
    Jul 2001
    Location
    KL, Malaysia
    Posts
    277
    Rep Power
    227
    CreateObject may not be available at brinkster if it is a free account.

  4. #4
    Join Date
    Mar 2002
    Location
    Kajang
    Posts
    18
    Rep Power
    0
    why not save your survey data into a database? you can make a page to display the data collected in the database. it is a lot more easier than sending yourself an email every time people answer your survey.

  5. #5
    Join Date
    Mar 2002
    Location
    Johor Bahru
    Posts
    14
    Rep Power
    0

    agreed with shahruzzaman

    yeah, i think using database is more efficient than email to collect data... i had tried before (using email) and need a lot of maintenance + editing to convert or collect etc....
    Taikucin.... wacchaaa.....!!!!!!!

  6. #6
    Join Date
    Mar 2002
    Posts
    13
    Rep Power
    0
    database is the foundation of any IS. no arguments there. you can do cool stuff with SQL against it. no arguments there either. perhaps alvinhan WANTED the results to be emailed as well.

  7. #7
    Join Date
    Dec 2001
    Location
    Labuan
    Posts
    83
    Rep Power
    219
    Thanks all guys who replied out there, my survey has been closed, it's all over. Thanks for all of the comments.
    aLvinHan of ViNSiGN Web Design in Labuan and PJ

  8. #8
    Join Date
    May 2002
    Location
    Kuala Lumpur, Malaysia
    Posts
    36
    Rep Power
    0
    If you are using brinkster server, you might probably facing problem on CDONTS, ASPMAiL or others scripts to sent emails..... coz it's FREE......... :P

  9. #9
    Join Date
    May 2002
    Location
    Kuala Lumpur, Malaysia
    Posts
    36
    Rep Power
    0
    <%
    ' #### You need CDONTS installed to be able to send mail
    ' #### Your sites information starts here ####
    ' Your Email Address - must be a valid domain or the mail will not send
    sYouEmail="you@yoursite.com"
    ' Email Subject
    EmailSubject="Someone has used the contact form"
    ' Heading font color
    FontColor="#5e007f"
    ' Heading Background Color
    HeadColor="#ffc500"
    ' Form Font Color
    FormFontColor="#ffc500"
    ' Form Background Color
    FormBackColor="#5e007f"
    'Error Message Color
    ErrorColor="red"
    ' That's it! - you may now wish to customize the header and footer files to suit your site.
    ' ################################################## ##################################

    Function ValidateField(sFieldvalue, sFieldtype)
    ValidField = true
    Select Case LCase(sFieldtype)
    Case "name"
    If Len(sFieldvalue) = 0 Then ValidField = False
    Case "email"
    If Len(sFieldvalue) < 5 Then
    ValidField = False
    Else
    If InStr(1, sFieldvalue, "@", 1) < 2 Then
    ValidField = False
    Else
    If InStr(1, sFieldvalue, ".", 1) < 4 Then
    ValidField = False
    End If
    End If
    End If
    Case "message"
    If Len(sFieldvalue) = 0 Then ValidField = False
    Case "else"
    ValidField = False
    End Select
    ValidateField = ValidField
    End Function
    Sub ShowForm
    %>
    <form action="<%= Request.ServerVariables("Script_Name") %>" method="post">
    <table border="0" cellspacing="0" width="240" cellpadding=0><tr bgcolor="<%=HeadColor%>">
    <td ALIGN="left"><B>Your name:</B>&nbsp;</td>
    </tr>
    <tr><td><input name="name" type="text" value="<%= Request.Form("name") %>" SIZE="45" style="FONT-SIZE: 11px; COLOR: <%=FormFontcolor%>; FONT-FAMILY: verdana, helvetica, arial; BACKGROUND-COLOR: <%=FormBackColor%>">
    </td>
    </tr><tr><td><%
    If dictFields(LCase("name")) Then
    Response.Write "<font color=""" & ErrorColor & """ face=""verdana,arial,helvetica"" size=-2>You need to enter your name</font>"
    Else
    Response.Write "&nbsp;"
    End If
    %>
    </td></tr>
    <tr bgcolor="<%=HeadColor%>">
    <td ALIGN="left"><font color="#5e007f" face="verdana,arial,helvetica" size="-1"><B>Your email address:</B></font>&nbsp;</td></tr>
    <tr><td><input name="email" type="text" value="<%= Request.Form("email") %>" SIZE="45" style="FONT-SIZE: 11px; COLOR: <%=FormFontcolor%>; FONT-FAMILY: verdana, helvetica, arial; BACKGROUND-COLOR: <%=FormBackColor%>">
    </td>
    </tr><tr><td><%
    If dictFields(LCase("email")) Then
    Response.Write "<font color=""" & ErrorColor & """ face=""verdana,arial,helvetica"" size=-2>You need to enter a valid email address</font>"
    Else
    Response.Write "&nbsp;"
    End If
    %>
    </td></tr>
    <tr bgcolor="<%=HeadColor%>">
    <td ALIGN="left"><font color="#5e007f" face="verdana,arial,helvetica" size="-1"><B>Your message:</B></font>&nbsp;</td></tr>
    <tr><td><TEXTAREA NAME="message" WRAP=VIRTUAL COLS="45" ROWS=7 style="FONT-SIZE: 11px; COLOR: <%=FormFontcolor%>; FONT-FAMILY: verdana, helvetica, arial; BACKGROUND-COLOR: <%=FormBackColor%>"><%= Request.Form("message") %></TEXTAREA></td>
    </tr><tr><td><%
    If dictFields(LCase("message")) Then
    Response.Write "<font color=""" & ErrorColor & """ face=""verdana,arial,helvetica"" size=-2> You need to enter a message</font>"
    Else
    Response.Write "&nbsp;"
    End If
    %>
    </td></tr>
    <tr><td colspan=2>
    <input type="checkbox" name="agree" value="true" <%
    if Len(Request.Form("agree")) > 0 then
    Response.Write "checked"
    End If
    %>> Tick here if you wish to be included on our mailing list.
    </td></tr>
    </table><p><input type="submit" value="Send Message">
    <br>
    </form>
    <P>
    <%
    End Sub
    Sub Send
    sPunter = Request.Form("Name")
    sPunterEmail = Request.Form("Email")
    Message = Request.Form("message")
    If Request.Form("agree") = "true" then
    Mailout = "They wish to be included on the mailing list"
    Else
    Mailout ="They DO NOT wish to be included on the mailing list"
    End If
    sMessage = "This is a message from " & sPunter & vbcrlf _
    & vbcrlf _
    & vbcrlf _
    & Message & vbcrlf _
    & vbcrlf _
    & "Their email is: " & sPunterEmail & vbcrlf _
    & vbcrlf _
    & Mailout & vbcrlf _
    & vbcrlf
    Set objNewMail = CreateObject("CDONTS.NewMail")
    objNewMail.Send sPunterEmail, sYouEmail, EmailSubject, sMessage
    Set objNewMail = Nothing
    End Sub

    Set dictFields = Server.CreateObject("Scripting.Dictionary")
    For Each Field in Request.Form
    If ValidateField(Request.Form(Field), Field) = False Then
    dictFields.Add LCase(Field), true
    End If
    Next
    If Request.Form.Count <> 0 And dictFields.Count = 0 Then
    %>
    <B>Your message has been mailed!<BR></B><P><B><I>Thank you for contacting us. A reply will be sent soon.</I></B><BR>
    <%
    Call Send
    Else
    ShowForm
    End If
    %>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Matrimonial Script with new feature, shaadi.com clone script
    By sahil101 in forum Website Programming
    Replies: 1
    Last Post: 14-10-2009, 01:23 PM
  2. How To Convert Shell Script to Batch Script
    By nana86 in forum Website Programming
    Replies: 0
    Last Post: 20-07-2007, 10:04 AM
  3. send contact us form to email
    By nanazack in forum Website Programming
    Replies: 2
    Last Post: 04-04-2007, 11:14 PM
  4. send var
    By ciki in forum Website Programming
    Replies: 21
    Last Post: 19-02-2004, 03:28 PM
  5. good form emailing php script
    By kelly001 in forum Website Programming
    Replies: 2
    Last Post: 04-06-2002, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112