Link to home
Start Free TrialLog in
Avatar of jasonmichel
jasonmichel

asked on

Collecting data from webform php/asp

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
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

do u need to insert in database or just u need send as an email ..??

I can help u , IN ASP . ??
Avatar of jasonmichel
jasonmichel

ASKER

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
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

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?
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

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

You can use it any way ...

Good Luck :)
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?
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


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>
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 ...
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
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

i checked with my hosting provider, they don't require authentication to send mail. so i should be fine without those credentials correct?
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# 
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

so save this as ASP and set the form action to this?
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

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

@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.
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.
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?
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.
ok  let me try that..thanks
hmm..thats not working either..its just outputting the code


http://www.ncitc.com/sendmail.php 
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

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

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
ASKER CERTIFIED SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
worked like a charm thanks!
Phew...that was a long Q, LOL.
i know..but you saved me hours of frustration..thanks!
You're welcome.