?
Solved

Collecting data from webform php/asp

Posted on 2010-01-12
34
Medium Priority
?
460 Views
Last Modified: 2012-05-08
I inserted a form in my contacts page in dreamweaver cs4 and populated with text fields to collect.  To get this to email to me i guess i need a php or asp script to send it.  Could someone help me out with that?

Thanks
0
Comment
Question by:jasonmichel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 9
  • 8
34 Comments
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295062
do u need to insert in database or just u need send as an email ..??

I can help u , IN ASP . ??
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26295246
just need it emailed...nothing fancy, i tried using php, but it don't seem to work, i am attaching my html/php that i have currently
contact.php
contact.html
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295367
u can try d below asp code .. PHP NO idea ...

<%
Function email(name1,From,To,Subject,Body)
	Dim mailobj
	Set mailobj = Server.CreateObject("Persits.MailSender")
	mailobj.Username = "urdomain@gdf.com"
	mailobj.Password = "urpassword"
	mailobj.Host = "domain.com"
	mailobj.From = name1
	mailobj.FromName = FromMail
	mailobj.AddAddress ToMail
	mailobj.AddReplyTo FromMail, FromMail
	mailobj.Subject = Subject
	mailobj.Body = Body
	mailobj.IsHTML = True
	mailobj.Send
	Set mailobj = Nothing
End Function

name2= Request.Form("Your Name")
fromemail="someemail@domain.com"
toemail =Request.Form("E-Mail")
subject = "YOUR Subject"
Body = Request.Form("comments")
email(name2,fromemail,toemail,subject,Body)
%>

Open in new window

0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 1

Author Comment

by:jasonmichel
ID: 26295397
i don't necessarily need to use php, ill use ASP if you can help me get it working..could you explain what i need to change in this script.  i assume i just copy paste into notepad and name something like sendmail.asp  as far as getting the form to use it when submit is hit? should I just set the action in the html as the sendmail.asp?
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295527
Here's ur ASP File , Save ur html page to asp  .

Just Replace with ur EMAIL Credentials

Hope it helps

Meeran 03:)



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Send Email Test</title>
</head>

<body>

<%
sub email(name1,From,Tomail,Subject,Body)
If Not Request.ServerVariables("REMOTE_ADDR") = Request.ServerVariables("LOCAL_ADDR") Then
	Dim mailobj
	Set mailobj = Server.CreateObject("Persits.MailSender")
	mailobj.Username = "urdomain@gdf.com"
	mailobj.Password = "urpassword"
	mailobj.Host = "ur.domain.com"
	mailobj.From = name1
	mailobj.FromName = FromMail
	mailobj.AddAddress ToMail
	mailobj.AddReplyTo FromMail, FromMail
	mailobj.Subject = Subject
	mailobj.Body = Body
	mailobj.IsHTML = True
	mailobj.Send
	Set mailobj = Nothing
end if
End sub

If Request.Form("submit") = "submit" then 
Response.Write("Calling Email")
name2= Request.Form("Name")
fromemail="someemail@domain.com"
toemail =Request.Form("EMail")
subject = "YOUR Subject"
Body = Request.Form("comments")
call email(name2,fromemail,toemail,subject,body)
end if
%>

<form action="#" method="post">
Name :<input type="text" name="Name" />
Email:<input type="text" name="EMail" />
Comments:<input type="text" name="comments" />
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>

Open in new window

0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295557
oops I dint read this ..
>>should I just set the action in the html as the sendmail.asp?

YEs u can just set d action such a way...


<form action="sendemail.asp" method="post">
Name :<input type="text" name="Name" />
Email:<input type="text" name="EMail" />
Comments:<input type="text" name="comments" />
<input type="submit" name="submit" value="submit"/>
</form>

Open in new window

0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295569
You can use it any way ...

Good Luck :)
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26295579
so i can keep my current form/html page for contacts the same, just save this as an asp then set the action for the form to point to the asp?
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26295611
sub email(name1,From,Tomail,Subject,Body)
If Not Request.ServerVariables("REMOTE_ADDR") = Request.ServerVariables("LOCAL_ADDR") Then
        Dim mailobj
        Set mailobj = Server.CreateObject("Persits.MailSender")
        mailobj.Username = "urdomain@gdf.com"
        mailobj.Password = "urpassword"
        mailobj.Host = "ur.domain.com"
        mailobj.From = name1
        mailobj.FromName = FromMail
        mailobj.AddAddress ToMail
        mailobj.AddReplyTo FromMail, FromMail
        mailobj.Subject = Subject
        mailobj.Body = Body
        mailobj.IsHTML = True
        mailobj.Send
        Set mailobj = Nothing


What needs changed in the above?


So all i really need to change in the following is to, from and subject?



If Request.Form("submit") = "submit" then
Response.Write("Calling Email")
name2= Request.Form("Name")
fromemail="someemail@domain.com"
toemail =Request.Form("EMail")
subject = "YOUR Subject"
Body = Request.Form("comments")
call email(name2,fromemail,toemail,subject,body)
end if


0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295620
offcourse .

Make sure you have your name field wat i mentioned .. Have a same stuff . which i mentioned in block

<form action="sendemail.asp" method="post">
Name :<input type="text" name="Name" />
Email:<input type="text" name="EMail" />
Comments:<input type="text"  name="comments" />
<input type="submit" name="submit" value="submit" />
</form>
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26295833
hmmm...
to, from and subject ??
format like below,
sub email(name1,Tomail, From,Subject,Body)

then call like this ,...
call email(name2, toemail,fromemail,subject,body)


Trust me , der s nothing wrong sending in any order . No idea y u need in such a way..any change the order like above ...
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26295882
i didn't mean changing the order, just the variable definition

ie.

If Request.Form("submit") = "submit" then
Response.Write("Calling Email")
name2= Request.Form("Name")
fromemail="someemail@domain.com" ----changing this
toemail =Request.Form("EMail") -changing this
subject = "YOUR Subject" -changing this
Body = Request.Form("comments")
call email(name2,fromemail,toemail,subject,body)
end if
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 26296092
u need to change in the function

sub email(name1,From,Tomail,Subject,Body)

' YOU SHOULD HAVE THESE credentials inorder to send email
        mailobj.Username = "urdomain@gdf.com"
        mailobj.Password = "urpassword"
        mailobj.Host = "ur.domain.com"
.....................

'
I had formatted again , after seeing ur file .
If Request.Form("submit") = "submit" then
Response.Write("Calling Email")
name2= Request.Form("Name")
fromemail= Request.Form("EMail") '- Dont change Leave as it is, as u r getting user email here 
toemail = "jason.michel@ncitc.com"  '----You can change to any other email also 
subject = "Web Contact"             '-You can give any other text message also 
Body = Request.Form("comments")
call email(name2,fromemail,toemail,subject,body)
end if

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26296210
i checked with my hosting provider, they don't require authentication to send mail. so i should be fine without those credentials correct?
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26296713
i copy and pasted what you gave me into a notepad and saved as sendmail.asp,, i told the form to post to sendmail.asp.  I fill out my form and hit submit and i get

http://www.ncitc.com/sendmail.asp# 
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26297297
There's no need to use Persits send mail.

ASP: (Native CDO Sys)




<%
Dim objMessage, item, strBody, subject, toAddress, fromAddress, phone, fax
Dim body, resultMessage, name, address, comments

CDOMailIncludeResults = "Not Sent"

Sub sendmail(pFrom, pTo, pSubject, pBody)
    Dim objCDO
    Dim iConf
    Dim Flds

    Const cdoSendUsingPort = 2

    Set objCDO = Server.CreateObject("CDO.Message")
    Set iConf = Server.CreateObject("CDO.Configuration")

    Set Flds = iConf.Fields
    With Flds
        .Item(cdoSendUsingMethod) = cdoSendUsingPort
        .Item(cdoSMTPServer) = "localhost"
        .Item(cdoSMTPServerPort) = 25
        .Item(cdoSMTPconnectiontimeout) = 10
        .Update
    End With

    Set objCDO.Configuration = iConf

    objCDO.From = pFrom
    objCDO.To = pTo
    objCDO.Subject = pSubject
    objCDO.HTMLBody = pBody

    On Error Resume Next
    objCDO.Send
    If Err Then
        CDOMailIncludeResults="ERROR: "&err.number & " " & err.description & " " & err.source
    Else
        CDOMailIncludeResults="Sent"
    End If
    On Error Goto 0 

    Set ObjCDO = Nothing
    Set iConf = Nothing
    Set Flds = Nothing
End Sub

toAddress = "jason.michel@ncitc.com"
fromAddress = "postmaster@ncitc.com"
name = Request.Form("name")
phone = Request.Form("phone")
fax = Request.Form("ffax")
address = Request.Form("address")
body = "From: " & name & chr(10)
body = body & "E-Mail: " & email & chr(10)
body = body & "Address: " & address & chr(10)
body = body & "Phone: " & phone & chr(10)
body = body & "Fax: " & fax & chr(10)
body = body & Request.Form("comments")
subject = "Web Contact"

sendmail fromAddress, toAddress, subject, body 
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<title>Send E-Mail Test</title>
</head>

<body>
<h1><%=resultMessage%></h1>
</body>

</html>

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26297342
so save this as ASP and set the form action to this?
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26297415
And PHP:


<?php
$to = "jason.michel@ncitc.com";
$from = "postmaster@ncitc.com";
$subject = "Web Contact";
$email = $_POST["mail"];
$name = $_POST["nname"];
$address = $_POST["address"];
$phone = $_POST["phone"];
$fax = $_POST["ffax"];
$message = $_POST["comments"] ;
$headers = "From: " . $from;

$message = "From: " & $name & "\n";
$message .= "Address: " & $address & "\n";
$message .= "E-Mail: " & $email & "\n";
$message .= "Phone: " & $phone & "\n";
$message .= "Fax: " & $fax & "\n";
$message .= "Comments: " & $comments & "\n";

$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26297514
using the asp, this is what i get


<% Dim objMessage, item, strBody, subject, toAddress, fromAddress, phone, fax Dim body, resultMessage, name, address, comments CDOMailIncludeResults = "Not Sent" Sub sendmail(pFrom, pTo, pSubject, pBody) Dim objCDO Dim iConf Dim Flds Const cdoSendUsingPort = 2 Set objCDO = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") Set Flds = iConf.Fields With Flds .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "localhost" .Item(cdoSMTPServerPort) = 25 .Item(cdoSMTPconnectiontimeout) = 10 .Update End With Set objCDO.Configuration = iConf objCDO.From = pFrom objCDO.To = pTo objCDO.Subject = pSubject objCDO.HTMLBody = pBody On Error Resume Next objCDO.Send If Err Then CDOMailIncludeResults="ERROR: "&err.number & " " & err.description & " " & err.source Else CDOMailIncludeResults="Sent" End If On Error Goto 0 Set ObjCDO = Nothing Set iConf = Nothing Set Flds = Nothing End Sub toAddress = "jason.michel@ncitc.com" fromAddress = "postmaster@ncitc.com" name = Request.Form("name") phone = Request.Form("phone") fax = Request.Form("ffax") address = Request.Form("address") body = "Name: " & name & chr(10) body = body & "Address: " & address & chr(10) body = body & "Phone: " & phone & chr(10) body = body & "Fax: " & fax & chr(10) body = body & Request.Form("comments") subject = "Web Contact" sendmail fromAddress, toAddress, subject, body %>
<%=resultMessage%>

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26297517
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26298599
@jasonmichel

>using the asp, this is what i get

What is what youu get?  I don't see anything in your post.

If you want to see that the ASP version does work go to:

http://www.rodsdot.com/asp/Send-EMail-Using-ASP-And-CDO.asp and send yourself an e-mail.  The sending code is on the results page.
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26298620
Oh I see what you mean from the link. Do you have ASP configured on your server?  The page extension is asp but the server is not processing the code. It is just outputting it as though you have no ASP support.
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26298944
never thought of that...i assumed my web host would support asp, they actually don't on the unix server i am in, so i guess i need to use your PHP script.  so basically the same thing would apply?  just have to do it that way?
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26298984
Yes, have your form page post to the PHP mailer page. And of course your form page needs to be htm or php, not asp.
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299002
ok  let me try that..thanks
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299115
hmm..thats not working either..its just outputting the code


http://www.ncitc.com/sendmail.php 
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299121
heres the HTML how its written right now
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>


<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>NorthCoast IT Consulting, LLC</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #CBCB95}
.style5 {color: #FFFFFF}
.style7 {
	color: #666666;
	font-size: 12px;
}
.style9 {font-size: 12}
-->
</style>
<meta name="keywords" content="Cisco, HIPAA, Consulting, Consultant, LAN, WAN, Web, Internet, Email, Exchange, SQL, Design, MCSE, Installation, Network, Security, Network Security, Active Directory, Microsoft, Windows, Linux, Video Surveillance, CCTV, Card access, Alarm systems, Integration, engineer, computer support, Onsite, remote support, Infrastructure, Systems security, Access control, DVR, Geovision, Business Development, Vulnerability assessment, Emergency support, 24 X 7, Virus, Training, project management, Domain registration, Repair, Network +, network plus, CCNA, CCIE, upgrade, wiring, cat 5, cat 6, help desk, IT, database, Aspect, Mcafee, Norton, ">
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<body>

<table width="100%" style="height:100% " border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="268" valign="top">
	
	<table width="100%" style="height:100% " border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50%" valign="top" style="background:url(images/px_flash.jpg) top left repeat-x "></td>
        <td width="766" valign="top"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="766" height="268" id="FlashID" title="contact">
          <param name="movie" value="Fullheader0d7f.swf?button=5">
          <param name="quality" value="high">

          <param name="wmode" value="opaque">
          <param name="swfversion" value="6.0.65.0">
          <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you dont want users to see the prompt. -->
          <param name="expressinstall" value="Scripts/expressInstall.swf">
          <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
          <!--[if !IE]>-->
          <object type="application/x-shockwave-flash" data="Fullheader0d7f.swf?button=5" width="766" height="268">
            <!--<![endif]-->
            <param name="quality" value="high">

            <param name="wmode" value="opaque">
            <param name="swfversion" value="6.0.65.0">
            <param name="expressinstall" value="Scripts/expressInstall.swf">
            <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>

            <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
        </object></td>
        <td width="50%" valign="top" style="background:url(images/px_flash1.jpg) top right repeat-x "></td>
      </tr>
    </table>
	
	</td>
  </tr>

  <tr>
    <td height="434" valign="top">
	
	<table width="100%" style="height:100% " border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50%" valign="top" style="background-color:#5F5F50 "></td>
        <td width="766" valign="top">
		
		<table width="766" style="height:100% " border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="258" valign="top" style="background-image:url(images/px.gif) ">

			
			<table width="258" style="height:100% " border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td height="165" valign="top" style=" background:url(images/4banner.jpg) top left no-repeat ">
<div style="margin:26px 27px 0px 0px; " align="right">
<img src="images/5txx.gif" alt=""><br>
<div style="margin:5px 0px 0px 150px; "> 
  <div align="left"><span class="style1">NCITC<span class="style5"> engineers are</span> </span> available 24/7 365 days a year
    <strong class="light">.</strong></div>

</div>
</div>
				</td>
			  </tr>
			  <tr>
				<td height="269" valign="top" style="background:url(images/bg.gif) top left no-repeat ">&nbsp;</td>
			  </tr>
			</table>

			
			</td>

			<td width="508" valign="top" style="background-image:url(images/px1.gif) ">
			
			<table width="508" style="height:100% " border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="255" valign="top">
				
				<table width="255" style="height:100% " border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td height="16" valign="top"></td>
				  </tr>
				  <tr>

					<td height="418" valign="top" style="background:url(images/px2.gif) right repeat-y ">
					
					<table width="255" style="height:100%; background:url(images/bg1.gif) top right no-repeat " border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top" style="background:url(images/bg2.gif) bottom right no-repeat ">
<form style="margin: 0pt; padding: 0pt;" action="sendmail.php" method="POST" id="form">
                                      
                                      <div style="margin: 8px 20px 20px 31px;"><img src="images/4pic1.gif" alt="Contact Form" style="margin-right: 12px;"><strong class="yellow1 big">NCITC
Contact Form </strong><br>


                                      <img src="images/spacer.gif" alt="" height="19" width="1"><br>

                                      <strong class="yellow">Contact Form </strong><br> Please enter a detailed comment.<br>


                                      <br>


                                      <input name="nname" class="form" id="nname" value="Your Name" type="text"> <br><img src="images/spacer.gif" alt="" height="3" width="1"><br>


                                      <input name="mail" class="form" id="mail" value="E-Mail" type="text"><br><img src="images/spacer.gif" alt="" height="3" width="1"><br>



                                      <input name="ph" class="form" id="ph" value="Phone" type="text">
                                      <br>


                                      <img src="images/spacer.gif" alt="" height="3" width="1"><br>


                                      <input name="ffax" class="form" id="ffax" value="Fax" type="text">

                                      <br>


                                      <img src="images/spacer.gif" alt="" height="3" width="1"><br>


                                      <input name="address" class="form" id="address" value="Address" type="text"> <br>


                                      <img src="images/spacer.gif" alt="" height="3" width="1"><br>


                                      <textarea name="comments" cols="5" rows="5" class="textarea" id="comments" style="overflow: hidden;">&nbsp;Comments</textarea>
                                      <br>


                                      
                                      <div style="margin-top: 12px; margin-right: 8px;" align="right">
<img src="images/a1.gif" alt="" style="margin-right:7px; "><a href="#" class="yellow l" onClick="document.getElementById('form').reset()">reset</a><img src="images/spacer.gif" alt="" width="33" height="1"><img src="images/a1.gif" alt=""  style="margin-right:7px; "><a href="#" class="yellow l" onClick="document.getElementById('form').submit()">submit</a>
</div>
</div>

						
						</form></td>

                      </tr>
                    </table>
					
					</td>
				  </tr>
				 
				</table>

				
				</td>
                <td width="253" valign="top">
				
				<table width="253" style="height:100% " border="0" cellspacing="0" cellpadding="0">

                  <tr>
                    <td height="19" valign="top"></td>
                  </tr>
				   <tr>
                    <td height="418" valign="top" style="background:url(images/bg3.gif) top left no-repeat ">
<div style="margin:8px 22px 20px 17px; ">
  <div align="center">
    <p><img src="images/4pic1.gif" alt="" style="margin-right:12px; "><strong class="yellow1 big">Contact Info </strong><br>
      <img src="images/spacer.gif" alt="" width="1" height="18"><br>

      <strong class="yellow">Phone:<br>
        </strong>
      Corporate Office: 419-217-0383<br><br>
      <strong class="yellow">Address:</strong><br><br>
      821 E. Main St.<br>
      Bellevue, Ohio 44811<br>

      <br><br>
      <a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=821+e.+Main+st++bellevue,+ohio&sll=37.0625,-95.677068&sspn=47.080837,109.248047&ie=UTF8&hq=&hnear=821+E+Main+St,+Bellevue,+Huron,+Ohio+44811&z=16&iwloc=A">Get Directions</a>
      <br>
      <span class="style9"><br>
        <img src="images/spacer.gif" alt="" width="1" height="16"><br>
        <span class="style1"><strong class="yellow">Email</strong>:</span></span><br>
      <br>

      Sales<br>
      <a href="mailto:Sales@ncitc.com">Sales@ncitc.com</a>    <br>
      <br>
      Support<br>
      <a href="mailto:Support@ncitc.com">Support@ncitc.com</a><br>
      <br>

      Customer Service<br>
      <a href="mailto:Service@ncitc.com">CustomerService@ncitc.com<br>
        </a>    <br>
      <br>
      <span class="style7"><img src="images/spacer.gif" alt="" width="1" height="16"></span><span class="style1"><strong class="yellow">Business Management:<br>
        </strong></span><br>
      Jason Michel- Owner<br>

      <a href="mailto:jason.michel@ncitc.com">Jason.Michel@ncitc.com</a><br>
      <br>
      Brian House- Consultant/Engineer<br>
      <a href="mailto:brian.house@ncitc.com">Brian.House@nctic.com</a>  <img src="images/spacer.gif" alt="" width="1" height="16"><br>
      <br>
      <span class="style7"><img src="images/spacer.gif" alt="Career" width="1" height="16"></span><span class="style1"><strong class="yellow">Career Opportunities:<br>

        <br>
        </strong><a href="mailto:career@ncitc.com">PostResume@Ncitc.com</a> </span><br>
      <br>
      <br>
    </p>
</div>
  <div style="margin-top:12px; margin-right:8px; " align="right"></div>
</div>

					
					</td>
                  </tr>
                </table>
				
				</td>
              </tr>
            </table>
			
			
			
			</td>
		  </tr>
		</table>

		
		</td>
        <td width="50%" valign="top" style="background-color:#4D4D44 "></td>
      </tr>
    </table>
	
	</td>
  </tr>
  <tr>
    <td height="78" valign="top">

	
	<table width="100%" style="height:100% " border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td width="766" valign="top" style="background-image:url(images/bg_copy.gif) ">
		
		<table width="766" style="height:100% " border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="508" valign="top">
<div style="margin:37px 0px 0px 22px; " class="yellow1"><span class="yellow1" style="margin:37px 0px 0px 22px; ">NorthCoast IT Consulting.com</span><span class="white">&copy; 2010 |</span> <a href="privacy.html" class="yellow1">Privacy Policy</a></div>

			
			</td>
			<td width="258" valign="top">
<div style="margin-top:27px; "></div>			
			</td>
		  </tr>
		</table>

		
		</td>
		<td width="50%" valign="top" style="background:url(images/px_right1.gif) top repeat-x "></td>
	  </tr>

	</table>

	
	</td>
  </tr>
   <tr>
    <td height="100%" valign="top" style="background-color:#212222 "></td>
  </tr>
</table>
<script type="text/javascript">
<!--
swfobject.registerObject("FlashID");
//-->
</script>
</body>


</html>

Open in new window

0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26299199
Then the attached should be saved as sendmail.php.

method="POST" should be method="post" and

<a href="#" class="yellow l" onClick="document.getElementById('form').submit()">submit</a>

Should be eliminated and replaced by

<input type="submit" value="Submit">

Don't use anchor tags (hyperlinks) for buttons.

http://www.rodsdot.com/javascript/Why-JavaScript-In-Hyperlinks-Is-Bad.asp

It would be nice if you format your code before asking someone to look through it.
<?php
$to = "jason.michel@ncitc.com";
$from = "postmaster@ncitc.com";
$subject = "Web Contact";
$email = $_POST["mail"];
$name = $_POST["nname"];
$address = $_POST["address"];
$phone = $_POST["ph"];
$fax = $_POST["ffax"];
$message = $_POST["comments"] ;
$headers = "From: " . $from;

$message = "From: " & $name & "\n";
$message .= "Address: " & $address & "\n";
$message .= "E-Mail: " & $email & "\n";
$message .= "Phone: " & $phone & "\n";
$message .= "Fax: " & $fax & "\n";
$message .= "Comments: " & $comments & "\n";

$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299300
thanks, that got the form to email correctly but didn't pull any data from it, just some characters..weird..i am attaching the screenshot of what it looks like.  What formatting should i do before posting?  Sorry if it was hard to read
Screenshot.png
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 2000 total points
ID: 26299439
I made an error and used the ASP concatenation operator rather than the PHP operator (hazards of writing two languages in the same thread.)  Sorry for my error.

Also, I think it would be beneficial to set a few additional headers to help mail clients properly render the message.

Attached is a new sendmail.php
<?php
$to = "jason.michel@ncitc.com";
$from = "postmaster@ncitc.com";
$subject = "Web Contact";
$email = $_POST["mail"];
$name = $_POST["nname"];
$address = $_POST["address"];
$phone = $_POST["ph"];
$fax = $_POST["ffax"];
$message = $_POST["comments"] ;

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
$headers .= 'Reply-To: webmaster@rodsdot.com' . "\r\n";

$message = "From: " . $name . "\n";
$message .= "Address: " . $address . "\n";
$message .= "E-Mail: " . $email . "\n";
$message .= "Phone: " . $phone . "\n";
$message .= "Fax: " . $fax . "\n";
$message .= "Comments: " . $comments . "\n";

$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

Open in new window

0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299504
worked like a charm thanks!
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26299520
Phew...that was a long Q, LOL.
0
 
LVL 1

Author Comment

by:jasonmichel
ID: 26299597
i know..but you saved me hours of frustration..thanks!
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 26299619
You're welcome.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question