PHP form not sending to email problem

  • sthebest
  • Born
  • Born
  • sthebest
  • Posts: 3

Post 3+ Months Ago

hi all. im trying to code a simple form for people to fll out if they are interested in booking a reservation (its a site for a Charter Boat site). here is what the code for the form looks like:

HTML Code: [ Select ]
<form action="gdform.asp" method="post">
<input type="hidden" name="subject" value="Form Submission" />
<input type="hidden" name="redirect" value="thanks.html" />
<input type="hidden" name="email" value="email address goes here" />
<p style="font-weight:bold;font-family:sans-serif;">Thank you for your interest in booking a reservation with KO Charters. We appreciate your patronage. Please
fill out the form below and a representative will get back to you as soon as possible.</p>
<p style="font-family:sans-serif;font-size:12px;">Email: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="TEXT" name="email"><br/>
<p style="font-family:sans-serif;font-size:12px;">First Name:&nbsp; <input type="TEXT" name="Firstname"><br/>
<p style="font-family:sans-serif;font-size:12px;">Last Name:&nbsp;&nbsp; <input type="TEXT" name="Lastname"><br/>
<p style="font-family:sans-serif;font-size:12px;">Address: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="address"><br/>
<p style="font-family:sans-serif;font-size:12px;">City: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="b.city"><br/>
<p style="font-family:sans-serif;font-size:12px;">State: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="c.state"><br/>
<p style="font-family:sans-serif;font-size:12px;">Zip Code: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="c.zip"><br/>
<p style="font-family:sans-serif;font-size:12px;">Telephone: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="phone"><br/>
<p style="font-family:sans-serif;font-size:12px;">Number of Passengers: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="no.passengers"><br/>
<p style="font-family:sans-serif;font-size:12px;">Charter Date: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="date"><br/>
<p style="font-family:sans-serif;font-size:12px;">Desired Package: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="package"><br/>
<p style="font-family:sans-serif;font-size:12px;">Desired Extras: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="extras"><br/>
<p style="font-size:9px;color:red;font-family:sans-serif;">*Your information will be kept confidential with KO Charters and
will never be sold or shared by third parties.</p>
<input type="submit" name="submit" value="submit"/>
  1. <form action="gdform.asp" method="post">
  2. <input type="hidden" name="subject" value="Form Submission" />
  3. <input type="hidden" name="redirect" value="thanks.html" />
  4. <input type="hidden" name="email" value="email address goes here" />
  5. <p style="font-weight:bold;font-family:sans-serif;">Thank you for your interest in booking a reservation with KO Charters. We appreciate your patronage. Please
  6. fill out the form below and a representative will get back to you as soon as possible.</p>
  7. <p style="font-family:sans-serif;font-size:12px;">Email: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="TEXT" name="email"><br/>
  8. <p style="font-family:sans-serif;font-size:12px;">First Name:&nbsp; <input type="TEXT" name="Firstname"><br/>
  9. <p style="font-family:sans-serif;font-size:12px;">Last Name:&nbsp;&nbsp; <input type="TEXT" name="Lastname"><br/>
  10. <p style="font-family:sans-serif;font-size:12px;">Address: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="address"><br/>
  11. <p style="font-family:sans-serif;font-size:12px;">City: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="b.city"><br/>
  12. <p style="font-family:sans-serif;font-size:12px;">State: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="c.state"><br/>
  13. <p style="font-family:sans-serif;font-size:12px;">Zip Code: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="c.zip"><br/>
  14. <p style="font-family:sans-serif;font-size:12px;">Telephone: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="phone"><br/>
  15. <p style="font-family:sans-serif;font-size:12px;">Number of Passengers: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="no.passengers"><br/>
  16. <p style="font-family:sans-serif;font-size:12px;">Charter Date: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="date"><br/>
  17. <p style="font-family:sans-serif;font-size:12px;">Desired Package: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="package"><br/>
  18. <p style="font-family:sans-serif;font-size:12px;">Desired Extras: &nbsp;&nbsp;&nbsp;<input type="TEXT" name="extras"><br/>
  19. <p style="font-size:9px;color:red;font-family:sans-serif;">*Your information will be kept confidential with KO Charters and
  20. will never be sold or shared by third parties.</p>
  21. <input type="submit" name="submit" value="submit"/>


Can anyone tell me why it is not sending the results of the form to an email address? Your help would be much appreciated!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Well the subject of your post says "PHP form not sending to email problem" but your action in your form is sending it to an ASP script "<form action="gdform.asp" method="post">"

Which is it? php or asp?, and what is your asp/php script code?
  • sthebest
  • Born
  • Born
  • sthebest
  • Posts: 3

Post 3+ Months Ago

Well the page itself is a PHP document, but Im using a ASP form to send the results to an email address. should I change the code to send to a PHP instead (and in turn place the php script on the server)?

Here is the ASP script code:

ASP Code: [ Select ]
<%
 
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
%>
  1. <%
  2.  
  3. Dim landing_page, host_url
  4. Dim fso, outfile, filename, dirname, myFolder
  5. Dim req_method, key, value
  6. Dim bErr, errStr, bEmpty
  7. On Error resume next
  8. bErr = false
  9. bEmpty = true
  10. errStr = ""
  11. Set fso = Server.CreateObject("Scripting.FileSystemObject")
  12. host_url = Request.ServerVariables("HTTP_HOST")
  13. req_method = Request.ServerVariables("REQUEST_METHOD")
  14. dtNow = Now()
  15. filename = Server.MapPath("\ssfm")
  16. dirname = filename
  17. filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)
  18.  
  19. Function FormatVariableLine(byval var_name, byVal var_value)
  20.    Dim tmpStr
  21.    tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
  22.    tmpStr = tmpStr & var_value & vbCRLF
  23.    tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
  24.    FormatVariableLine = tmpStr
  25. end function
  26.  
  27. Sub OutputLine(byVal line)
  28.    outfile.WriteLine(line)
  29. end sub
  30.  
  31. if err.number = 0 then
  32.    Set outfile = fso.CreateTextFile(filename, true, false)
  33.    if err.number <> 0 then
  34.          bErr = true
  35.          errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
  36.    else
  37.       if(req_method = "GET") then
  38.          for each Item in request.QueryString
  39.             if item <> "" then
  40.                bEmpty = false
  41.                key = item
  42.                value = Request.QueryString(item)
  43.                if(lcase(key) = "redirect") then
  44.                   landing_page = value
  45.                else
  46.                   line = FormatVariableLine(key, value)
  47.                   Call OutputLine(line)
  48.                end if
  49.             end if   
  50.          next
  51.       elseif (req_method = "POST") then
  52.          for each Item in request.form
  53.             if item <> "" then
  54.                bEmpty = false
  55.                key = item
  56.                value = Request.form(item)
  57.                if(lcase(key) = "redirect") then
  58.                   landing_page = value
  59.                else
  60.                   line = FormatVariableLine(key, value)
  61.                   Call OutputLine(line)
  62.                end if
  63.             end if   
  64.          next
  65.       end if
  66.       outfile.close
  67.    end if  
  68.    if(bEmpty = true) AND errStr = "" then
  69.       bErr = true
  70.       errStr = errStr & "<br>No variables sent to form! Unable to process request."
  71.    end if
  72.    if(bErr = false) then   
  73.       if (landing_page <> "") then
  74.          response.Redirect "http://" & host_url & "/" & landing_page
  75.       else
  76.          response.Redirect "http://" & host_url
  77.       end if
  78.    else
  79.       Response.Write errStr
  80.    end if  
  81.    set fso = nothing
  82. else
  83.   Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
  84. end if
  85. %>



Forgive me for asking so many questions but Im a graphic designer by nature who coincidentally happens to do a little web design.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 70 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.