Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 109,543 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 1,201 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Godaddy hosting e-mail form (classic ASP)

 
Reply to this topicStart new topic

Godaddy hosting e-mail form (classic ASP)

iLLfLiP
post 4 Aug, 2008 - 09:10 AM
Post #1


New D.I.C Head

*
Joined: 29 Jan, 2008
Posts: 13

Hi, I am currently using GoDaddy as my ASP.NET / ASP hosting service and am working on an e-mail form. The form works fine and allows a user to input information and then submit it (e-mail information gets sent to me).

However, I am trying to add one text field, which will allow a user to input an e-mail address and then have that same information that is automatically sent to me, also sent to the user. In other words, pretty much copy the user on the e-mail sent.
I'm not the best ASP coder and am using just about all the code/script provided default by GoDaddy; however I would like to add this feature. Please see my code below and advise. Thanks in advance:

CODE

<h1>Creative Brief</h1>
<form method="POST" action="gdform.asp">
Fields marked (*) are required

<div style="float:right">
<p>Final Due Date:<br>
<input type="text" name="FinalDueDate">
</div>
<p>Email From:* <br>
<input type="text" name="EmailFrom">
<p>Project:<br>
<input type="text" name="Project">
<p>Owner:<br>
<input type="text" name="Owner">
<p>Copy E-mail (form submission completed request):<br />
<input type="text" name="CopyMail" />
<br />
<br />

<h2>Design Specs</h2>
<select name="Designspecdropdown">
<option value="Website">Website</option>
<option value="Banners/Logos">Banners/Logos</option>
<option value="Email">Email</option>
<option value="Print">Print</option>
<option value="InterOFfice">Inter-Office</option>
</select>

<p>Size(HxW):<br>
<input type="checkbox" name="Size" value="120x60" />120x60
<input type="checkbox" name="Size" value="120x90" />120x90
<input type="checkbox" name="Size" value="125x125" />125x125
<input type="checkbox" name="Size" value="250x300" />250x300
<input type="checkbox" name="Size" value="468x60" />468x60
<br />
<input type="checkbox" name="Size" value="728x90" />728x90
<input type="checkbox" name="Size" value="120x60" />120x60
<input type="checkbox" name="Size" value="120x240" />120x240
<input type="checkbox" name="Size" value="120x600" />120x600
<input type="checkbox" name="Size" value="160x600" />160x600
<p><input type="checkbox" name="Size" value="Other" />Other:<br>
<input type="text" name="OtherInput" />
<br />
<br />

<h2>Copy / Messaging</h2>
<p>Main:<br>
<input type="text" name="Main">
<p>Primary:<br>
<input type="text" name="Primary">
<p>Secondary:<br>
<input type="text" name="Secondary">
<br />
<br />

<h2>Merchandising / Imagery</h2>
<p>Brand:<br>
<input type="text" name="Brand">
<p>Collection:<br>
<input type="text" name="Collection">
<p>Product Sku:<br>
<input type="text" name="ProductSku">
<p>Image to Use:<br>
<input type="text" name="ImagetoUse">
<p><input type="submit" name="submit" value="Submit">

</form>



ASP Code
CODE

<%

Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty
On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("\ssfm")
dirname = filename
filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)

Function FormatVariableLine(byval var_name, byVal var_value)
    Dim tmpStr
    tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
    tmpStr = tmpStr & var_value & vbCRLF
    tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
    FormatVariableLine = tmpStr
end function

Sub OutputLine(byVal line)
   outfile.WriteLine(line)
end sub

if err.number = 0 then
    Set outfile = fso.CreateTextFile(filename, true, false)
    if err.number <> 0 then
            bErr = true
            errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
    else
        if(req_method = "GET") then
            for each Item in request.QueryString
                if item <> "" then
                    bEmpty = false
                    key = item
                    value = Request.QueryString(item)
                    if(lcase(key) = "redirect") then
                        landing_page = value
                    else
                        line = FormatVariableLine(key, value)
                        Call OutputLine(line)
                    end if
                end if    
            next
        elseif (req_method = "POST") then
            for each Item in request.form
                if item <> "" then
                    bEmpty = false
                    key = item
                    value = Request.form(item)
                    if(lcase(key) = "redirect") then
                        landing_page = value
                    else
                        line = FormatVariableLine(key, value)
                        Call OutputLine(line)
                    end if
                end if    
            next
        end if
        outfile.close
    end if    
    if(bEmpty = true) AND errStr = "" then
        bErr = true
        errStr = errStr & "<br>No variables sent to form! Unable to process request."
    end if
    if(bErr = false) then    
        if (landing_page <> "") then
            response.Redirect "http://" & host_url & "/" & landing_page
        else
            response.Redirect "http://" & host_url    
        end if
    else
        Response.Write errStr
    end if    
    set fso = nothing
else
  Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if
%>

User is offlineProfile CardPM

Go to the top of the page


Martyr2
post 4 Aug, 2008 - 12:27 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,364



Thanked 83 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Is that asp code the code in gdform.asp? Because I don't see any actual emailing code in there. It just appears to be writing the form content to a file on their server. No emailing is involved there.

If it is not gdform.asp, show us the code for that. smile.gif
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 09:58PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month