Jump to content

[SOLVED] Very Simple Form/PHP Mail Setup - Need Help


cdinsmore

Recommended Posts

Let me first say hello and thanks for giving me the opportunity to learn what it is that I'm doing wrong ;)

 

I am building a very small company Intranet, and working on making a Submission form which sends an HTML formatted e-mail to the person who needs the input.

 

<!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">
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
	{
		if (value==null||value=="")
			{alert(alerttxt);return false}
		else {return true}
	}
}

function validate_form(thisform)
{
with (thisform)
{
	if (validate_required(Contributor,"You must type in your name!")==false)
		{Contributor.focus();return false}
	if (validate_required(NewsletterText,"You must enter Newsletter Text before submitting this form!")==false)
		{NewsletterText.focus();return false}
}

function formControl(submitted) 
{
   if(submitted=="1") 
    {
   commentForm.Submit.disabled=true
   alert("Thanks for your comments!")
    }
}
}
</script>
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ABR Intranet</title>
<link rel="stylesheet" href="emx_nav_left.css" type="text/css" />
</head>
<form action="takeform.php" method="post" onsubmit="return validate_form(this);" enctype="text/plain">
<div id="masthead">
  <div id="globalNav">
    <div id="globalLink">
<a href="Index.html" id="gl1" class="glink">Home</a>
<a href="Administration.html" id="gl2" class="glink">Administration</a>
<a href="Newsletter.html" id="g14" class="glink">Newsletter</a>
<a href="Information_Technology.html" id="gl3" class="glink">Information Technology</a>

  </div>
    <!-- end globalNav -->
</div>
<!-- end masthead -->
<div id="pagecell1">
  <!--pagecell1-->
  <img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl" /> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr" />
  <img src="ABRlogoRGBsm.jpg" height="100" />
  <div id="pageName">
  </div>
  <!-- Page Links -->
  <div id="pageNav">
    <div id="sectionLinks"> 
	<a href="Newsletter.html">Current Newsletter</a>
	<a href="NewsletterArchive.html">Archived Newsletters</a>
	<a href="NewsletterForm.html">Newsletter Submission Form</a></div>
  </div>
  <div id="content">
    
    <div class="pagecontent">
<!--Content Goes Here-->

<center><h1>Employee Newsletter Submission Form</h1>
<hr />
<font color="red" style="font-family:"Courier New", Courier, monospace">DEADLINE FOR SUBMISSION FOR NEXT PUBLICATION IS NOVEMBER 9TH, 2007</font>
<hr />
<p>The purpose of the ABR Employee Newsletter is to provide specialized information to everyone with the emphasis on keeping the lines of communication open in the office.  Each week at your departmental meeting, please set aside a few minutes to duscuss what should be included in the next Newsletter.</p>
</center>
<hr />
<p style="color:red">* Required Field</p>
<table width="80%">
<tr>
	<td width="270">* Submitting Department:</td>
	<td><select name="SubmittingDepartment">
			<option>Administration</option>
			<option>Finance</option>
			<option>MOC</option>
			<option>IC/TSD</option>
			<option>Information Technology</option>
			<option>Imaging</option>
		</select>
	</td>
</tr>
<tr>
	<td>* Contributor:</td>
	<td><input type="text" width="300" name="Contributor" /></td>
</tr>
<tr>
	<td>* Newsletter Text (Limit is 1000 words):</td>
	<td><textarea cols="50" rows="10" name="NewsletterText"></textarea></td>
</tr>
</table>
<br />
<table width="80%">
<tr>
	<td width="200">Upcoming Event -- </td><td>Description: <input type="text" width="300" name="EventDescription" /><td>Date: <input type="text" name="EventDate" /> </td>
</tr>
<tr>
	<td>Large Copy Job -- </td><td>Description: <input type="text" width="300" name="LrgCopyDescription" /><td>Date: <input type="text" name="LrgCopyDate" /> </td>
</tr>
<tr>
	<td>Mass E-Mail Distribution -- </td><td>Description: <input type="text" width="300" name="MassEmailDescription" /><td>Date: <input type="text" name="MassEmailDate" /> </td>
</tr>
<tr>
	<td>Letter Distribution -- </td><td>Description: <input type="text" width="300" name="LetterDescription" /><td>Date: <input type="text" name="LetterDate" /> </td>
</tr>
<tr>
	<td>Scheduled Maintenance -- </td><td>Description: <input type="text" width="300" name="Maintenanceescription" /><td>Date: <input type="text" name="MaintenanceDate" /> </td>
</tr>
</table>
<hr />
<h1>Office Visitors</h1>
<table width="700">
<tr>
	<td width="270">Who will be visiting?  </td>
	<td width="418"><input type="text" width="300" name="Visitor" /></td>
</tr>
<tr>
	<td>Which department will they be visiting?<br /><br /><font size="-2"  color="#FF0000">Hint: You can choose more than one department by holding down the CTRL key and clicking on the department name</font>  </td>
	<td><select name="VisitingDepartment" multiple="multiple" size="6">
			<option>Administration</option>
			<option>Finance</option>
			<option>MOC</option>
			<option>IC/TSD</option>
			<option>Information Technology</option>
			<option>Imaging</option>
		</select></td>
</tr>
<tr>
	<td>Date(s) of visit:  </td><td><input type="text" width="300" name="VisitDate" /></td>
</table>
<hr />
<input type="submit" value="Send to Ronda" /><input type="reset" value="Reset Fields"/>
</div>
<!--Content Ends Here-->
    <div class="pagecontent"></div>
  </div>
  <div></div>
    <div id="siteInfo"><a href="http://theabr.org">About Us</a> | <a href="file:////Minime/group/Shared/Administration/ABR Handbook.pdf">Privacy Policy</a> | <a href="mailto:admin@email.com">Contact Us</a> | ©2007 American Board of Radiology </div>
</div>
<!--end pagecell1-->
<br />
</form>
</html>

 

Which passes information to my very simple PHP form:

 

<!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" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Your Request Has Been Submitted</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>
<body>
<?php
$recipient = "email@email.com";
$from = "email@email.com";
$subject = "Newsletter Submission";
$SubmittingDepartment = $_POST['SubmittingDepartment'];
$Contributor = $_POST['Contributor'];
$NewsletterText = $_POST['NewsletterText'];
$EventDescription = $_POST['EventDescription'];
$EventDate = $_POST['EventDate'];
$LrgCopyDescription = $_POST['LrgCopyDescription'];
$LrgCopyDate = $_POST['LrgCopyDate'];
$MassEmailDescription = $_POST['MassEmailDescription'];
$MassEmailDate = $_POST['MassEmailDate'];
$LetterDescription = $_POST['LetterDescription'];
$LetterDate = $_POST['LetterDate'];
$MaintenanceDescription = $_POST['MaintenanceDescription'];
$MaintnenanceDate = $_POST['MaintenanceDate'];
$Visitor = $_POST['Visitor'];
$VisitingDepartment = $_POST['VisitingDepartment'];
$VisitDate = $_POST['VisitDate'];

$message = "<html><body><p><b>Submitting Department:</b>  $SubmittingDepartment<br /><b>Contributor:</b>  $Contributor<br /><b>Newsletter Text:</b>  $NewsletterText<br /><b>Upcoming Event:</b>  $EventDescription  <b>Date:</b>  $EventDate<br /><b>Large Copy Job:</b>  $LrgCopyDescription  <b>Date:</b>  $LrgCopyDate<br /><b>Mass E-mail Distribution:</b>  $MassEmailDescription  <b>Date:</b>  $MassEmailDate<br /><b>Letter Distribution:</b>  $LetterDescription  <b>Date:</b>  $LetterDate<br /><b>Scheduled Maintenance:</b>  $MaintenanceDescription  <b>Date:</b> $MaintnenanceDate<br /><b>Visitor:</b>  $Visitor  <b>Will be visiting:</b>  $VisitingDepartment on:  $VisitDate<br /></body></html>";
//In case any of the lines are larger than 70 characters, use wordwrap
$message = wordwrap($message, 70);
	  
$headers = "From: $from\nContent-Type: text/html; charset=iso-8859-1";

ini_set("SMTP","my.email.server");
    # Send the email
   	mail($recipient, $subject, $message, $headers);
  
echo("<p>Your message has been sent. Thank you!</p>\n");
?>
</body>
</html>

 

Currently, the output that I'm receiving is the correct HTML formatting, but none of the data from NewsletterForm.html is showing up.

 

<b>Submitting Department:</b><br /><b>Contributor:</b><br /><b>Newsletter Text:</b><br /><b>Upcoming Event:</b> <b>Date:</b> <br /><b>Large Copy Job:</b>  <b>Date:</b><br /><b>Mass E-mail Distribution:</b><b>Date:</b><br /><b>Letter Distribution:</b><b>Date:</b>  <br /><b>Scheduled Maintenance:</b><b>Date:</b><br /><b>Visitor:</b><b>Will be visiting:</b>  on:  <br />

 

I've tried $_REQUEST, $_GET, and $_POST.

 

I realize that there are many more secure ways to be able to do this per my readings on PHP tutorials... but I'm really just looking for what it is that I'm doing wrong in terms of passing information from NewsletterForm to takeform.

 

Thank you in advance!!!

Link to comment
Share on other sites

Try this in your php file

<!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" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Your Request Has Been Submitted</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>
<body>
<?php
$recipient = "email@email.com";
$from = "email@email.com";
$subject = "Newsletter Submission";
$SubmittingDepartment = $_POST['SubmittingDepartment'];
$Contributor = $_POST['Contributor'];
$NewsletterText = $_POST['NewsletterText'];
$EventDescription = $_POST['EventDescription'];
$EventDate = $_POST['EventDate'];
$LrgCopyDescription = $_POST['LrgCopyDescription'];
$LrgCopyDate = $_POST['LrgCopyDate'];
$MassEmailDescription = $_POST['MassEmailDescription'];
$MassEmailDate = $_POST['MassEmailDate'];
$LetterDescription = $_POST['LetterDescription'];
$LetterDate = $_POST['LetterDate'];
$MaintenanceDescription = $_POST['MaintenanceDescription'];
$MaintnenanceDate = $_POST['MaintenanceDate'];
$Visitor = $_POST['Visitor'];
$VisitingDepartment = $_POST['VisitingDepartment'];
$VisitDate = $_POST['VisitDate'];

$message = "<html><body><p><b>Submitting Department:</b>  ".$SubmittingDepartment."<br /><b>Contributor:</b>  ".$Contributor." <br /><b>Newsletter Text:</b>  ".$NewsletterText." <br /><b>Upcoming Event:</b>  ".$EventDescription."  <b>Date:</b>  ".$EventDate."<br /><b>Large Copy Job:</b>  ".$LrgCopyDescription."  <b>Date:</b>  ".$LrgCopyDate."<br /><b>Mass E-mail Distribution:</b>  ".$MassEmailDescription."  <b>Date:</b>  ".$MassEmailDate."<br /><b>Letter Distribution:</b>  ".$LetterDescription."  <b>Date:</b>  ".$LetterDate." <br /><b>Scheduled Maintenance:</b>  ".$MaintenanceDescription."  <b>Date:</b> ".$MaintnenanceDate."<br /><b>Visitor:</b>  ".$Visitor."  <b>Will be visiting:</b>  ".$VisitingDepartment." on:  ".$VisitDate."<br /></body></html>";
//In case any of the lines are larger than 70 characters, use wordwrap
$message = wordwrap($message, 70);
	  
$headers = "From: $from\nContent-Type: text/html; charset=iso-8859-1";

ini_set("SMTP","my.email.server");
    # Send the email
   	mail($recipient, $subject, $message, $headers);
  
echo("<p>Your message has been sent. Thank you!</p>\n");
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.