I have used this form template and php template in the past with success, but I tried adapting it today and although it will email me, the email is completely blank. I'm hoping you can help me identify why this is.

The form:

<form onsubmit="return validate();" method="post" name="membership_form"
action=http://www.apvcalgary.com/membership_form.php><!--
<input name="event" size="30" type="hidden" value="Membership" />
--><label>Membership: <select name="Event"> <option selected
value=oneyear>One Year Membership with APVCS</option></select></label><label class="highlight">Legal Name: <input size="30"
name=legalname> </label><label>Name that appears on Facebook (leave blank if the same): <input size="30" name="fbname"> </label><label
class=highlight> Preferred Email: <input size="30" name="email"> </label><label>How did you
hear about us?<input size="30" name="How_did_you_hear_about_us"> </label> Please select your payment method: <br>
<div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox"
name=Paypal[]> Paypal (you do not need a pp account to pay by credit card with them) </div> <label> Name Or Company associated with your PP account if applicable <input size="30" name="ppname"> </label> <div class="radio_checkbox padded"><input value="Yes" type="checkbox"
name=EMT[]> Email Money Transfer (to apvillage@gmail.com) </div> <label> Name and email EMT will come from <input size="30" name="emtname"> </label><!--<div class="radio_checkbox highlight padded">
Radio Buttons:<br />

					<label>yes <input name="radio_buttons" value="yes" type="radio" /></label>

					<label>no <input name="radio_buttons" value="no" type="radio" /></label>
				</div>

				<div class="radio_checkbox padded">
					Check Boxes:<br /> --><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><!--<label>yes <input name="checkboxes[]" value="yes" type="checkbox" /></label>

					<label>no <input name="checkboxes[]" value="no" type="checkbox" /></label>
				</div> 

				<label class="highlight">-->

<div class="radio_checkbox padded"><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><input
value=Yes type=checkbox name=Terms> I understand how <a
href="#member" target=_blank> membership </a> works, and the expiration period (required for membership)</div><label
class=highlight>Questions/Comments: <textarea rows="4" cols="26" name="comments"></textarea> </label>
<div class="submit"><input value="submit" type="submit" name="submit_button">
</div></form>

The PHP:

<?php

function filter($input){
	$to_remove = array('~','`','{','}','^','[',']','<script>','</script>','<applet>','</applet>');
	$clean = trim(str_replace($to_remove, "-", $input));
	return $clean;
}

function cleanup_text_for_display($txt){
	$txt = str_replace('_',' ',$txt);
	$txt = ucwords($txt);
	//$txt = str_replace(' ','&nbsp;',$txt);
return $txt;

}

if(isset($_POST) && !empty($_POST)){

	$mail_content = "MEMBERSHIP FORM\r\n";
	$mail_content .= "-------------------------------\r\n";
	date_default_timezone_set('MST');
	$mail_content .= date('F j, Y, g:i a')."\r\n";

	$html_content = '<h2>Thank you for becoming a member!</h2>';

	$html_content .= '<p>If there are any errors in the information below <a href="mailto:info@apvcalgary.com">please let us know</a>.</p>';

	foreach($_POST as $key => $value){

		if(is_array($value)){

			$mail_content .= cleanup_text_for_display($key).': ';

			foreach($value as $item){

				$mail_content .= $item." ";

			}

			$mail_content .= "\r\n";

		}else{

			if($key == 'submit_button')
				continue;

			// build email content

			$mail_content .= cleanup_text_for_display($key).': '.$value."\r\n";

			// layout form data for display in web page

			$html_content .= '<p>'.cleanup_text_for_display($key).': '.$value.'</p>';

		}
	}
}

//,"From:apvillage@gmail.com\r\nReply-to:apvillage@gmail.com"

if(!mail(
	//'apvillage@gmail.com,
	'apvillage@gmail.com',
	'Membership Form',
	$mail_content
)){
	$html_content = '<h3>ERROR: Sorry, this message could not be sent.</h3>';
	$html_content .= 'Please try resubmitting the form.<br /><a href="http://www.apvcalgary.com/index.html"><< BACK </a>';
	$html_content .= '<br /><br />If this problem persists, please <a href="mailto:info@apvcalgary.com">let us know</a>. Thanks.';
}
else {
	header("location:http://www.apvcalgary.com/form_response.html");
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html><head><title>AP Village | Calgary</title>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link
rel=stylesheet type=text/css href="http://www.apvcalgary.com/styles.css">
<meta name="GENERATOR" content="MSHTML 8.00.6001.19170">

</head>
<body>
<div id="leftSideBar">
<div id="apvcImg">
<div id="top_text">
</div>
<div class="nav">
<ul>
<li><a href="index.html">Home </a>
<li><a href="about.htm">About Us</a>
<li><a href="events.htm">Upcoming Events</a>
<li><a href="outdoorplay.htm">Summer Playgroup </a>
<li><a href="indoorplay.htm">Winter Playgroup</a>
<li><a href="member.htm">Become A Member</a>
<li><a href="lendinglibrary.htm">Carrier Lending Library</a>
<li><a href="faq.htm">FAQ</a>
<li><a href="links.htm">Links</a>
<li><a href="mailto:info@apvcalgary.com">Contact Us</a> </li></ul></div>

			<div class="content">

				<?php

					echo $html_content;

				?>

			</div>

		</div>

	<div>

<div id="footer">
	<a href="http://www.apvcalgary.com/terms.html">Terms &amp; Conditions</a> &nbsp; &bull; &nbsp; <a href="mailto:info@apvcalgary.com">Contact Us</a>
</div>

</body>
</html></html>

    When posting code, please use the formatting tags described in the FAQs to make your code easier to read.

      The form:
      <html>
      <form onsubmit="return validate();" method="post" name="membership_form"
      action=http://www.apvcalgary.com/membership_form.php><!--
      <input name="event" size="30" type="hidden" value="Membership" />
      --><label>Membership: <select name="Event"> <option selected
      value=oneyear>One Year Membership with APVCS</option></select></label><label class="highlight">Legal Name: <input size="30"
      name=legalname> </label><label>Name that appears on Facebook (leave blank if the same): <input size="30" name="fbname"> </label><label
      class=highlight> Preferred Email: <input size="30" name="email"> </label><label>How did you
      hear about us?<input size="30" name="How_did_you_hear_about_us"> </label> Please select your payment method: <br>
      <div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox"
      name=Paypal[]> Paypal (you do not need a pp account to pay by credit card with them) </div> <label> Name Or Company associated with your PP account if applicable <input size="30" name="ppname"> </label> <div class="radio_checkbox padded"><input value="Yes" type="checkbox"
      name=EMT[]> Email Money Transfer (to apvillage@gmail.com) </div> <label> Name and email EMT will come from <input size="30" name="emtname"> </label><!--<div class="radio_checkbox highlight padded">
      Radio Buttons:<br />

      <label>yes <input name="radio_buttons" value="yes" type="radio" /></label>

      <label>no <input name="radio_buttons" value="no" type="radio" /></label>
      </div>

      <div class="radio_checkbox padded">
      Check Boxes:<br /> --><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><!--<label>yes <input name="checkboxes[]" value="yes" type="checkbox" /></label>

      <label>no <input name="checkboxes[]" value="no" type="checkbox" /></label>
      </div>

      <label class="highlight">-->
      <div class="radio_checkbox padded"><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><input
      value=Yes type=checkbox name=Terms> I understand how <a
      href="#member" target=_blank> membership </a> works, and the expiration period (required for membership)</div><label
      class=highlight>Questions/Comments: <textarea rows="4" cols="26" name="comments"></textarea> </label>
      <div class="submit"><input value="submit" type="submit" name="submit_button">
      </div></form>
      </html>

      The PHP:
      <php>
      <?php

      function filter($input){
      $to_remove = array('~','`','{','}','','[',']','<script>','</script>','<applet>','</applet>');
      $clean = trim(str_replace($to_remove, "-", $input));
      return $clean;
      }

      function cleanup_text_for_display($txt){
      $txt = str_replace('_',' ',$txt);
      $txt = ucwords($txt);
      //$txt = str_replace(' ','&nbsp;',$txt);
      return $txt;
      }

      if(isset($POST) && !empty($POST)){

      $mail_content = "MEMBERSHIP FORM\r\n";
      $mail_content .= "-------------------------------\r\n";
      date_default_timezone_set('MST');
      $mail_content .= date('F j, Y, g:i a')."\r\n";

      $html_content = '<h2>Thank you for becoming a member!</h2>';

      $html_content .= '<p>If there are any errors in the information below <a href="mailto:info@apvcalgary.com">please let us know</a>.</p>';

      foreach($_POST as $key => $value){

      if(is_array($value)){

      $mail_content .= cleanup_text_for_display($key).': ';

      foreach($value as $item){

      $mail_content .= $item." ";

      }

      $mail_content .= "\r\n";

      }else{

      if($key == 'submit_button')
      continue;

      // build email content

      $mail_content .= cleanup_text_for_display($key).': '.$value."\r\n";

      // layout form data for display in web page

      $html_content .= '<p>'.cleanup_text_for_display($key).': '.$value.'</p>';

      }
      }
      }

      //,"From:apvillage@gmail.com\r\nReply-to:apvillage@gmail.com"

      if(!mail(
      //'apvillage@gmail.com,
      'apvillage@gmail.com',
      'Membership Form',
      $mail_content
      )){
      $html_content = '<h3>ERROR: Sorry, this message could not be sent.</h3>';
      $html_content .= 'Please try resubmitting the form.<br /><a href="http://www.apvcalgary.com/index.html"><< BACK </a>';
      $html_content .= '<br /><br />If this problem persists, please <a href="mailto:info@apvcalgary.com">let us know</a>. Thanks.';
      }
      else {
      header("location:http://www.apvcalgary.com/form_response.html");
      }

      ?>

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
      <html><head><title>AP Village | Calgary</title>
      <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
      <link
      rel=stylesheet type=text/css href="http://www.apvcalgary.com/styles.css">
      <meta name="GENERATOR" content="MSHTML 8.00.6001.19170">

      </head>
      <body>
      <div id="leftSideBar">
      <div id="apvcImg">
      <div id="top_text">
      </div>
      <div class="nav">
      <ul>
      <li><a href="index.html">Home </a>
      <li><a href="about.htm">About Us</a>
      <li><a href="events.htm">Upcoming Events</a>
      <li><a href="outdoorplay.htm">Summer Playgroup </a>
      <li><a href="indoorplay.htm">Winter Playgroup</a>
      <li><a href="member.htm">Become A Member</a>
      <li><a href="lendinglibrary.htm">Carrier Lending Library</a>
      <li><a href="faq.htm">FAQ</a>
      <li><a href="links.htm">Links</a>
      <li><a href="mailto:info@apvcalgary.com">Contact Us</a> </li></ul></div>

      <div class="content">

      <?php

      echo $html_content;

      ?>

      </div>

      </div>

      <div>

      <div id="footer">
      <a href="http://www.apvcalgary.com/terms.html">Terms &amp; Conditions</a> &nbsp; &bull; &nbsp; <a href="mailto:info@apvcalgary.com">Contact Us</a>
      </div>

      </body>
      </html></html>
      </php>

        When posting code, please use the formatting tags described in the FAQs to make your code easier to read.

          I clearly don't understand what is required. I added the <html> and <php> tags as per the faq - what else am I missing that is preventing me from getting any tangible help on this?

            See the section titled Extra board markup in this forum's FAQ and compare what it shows with what you've posted.

            You should also read the General Guidelines; smacking a big wodge of stuff up and say "it's not working" is not enough to get people who already have their own stuff to work on to drop it and work on your stuff.

              Wasn't indicating people should drop everything.
              However, if I'm clearly not doing it right and I've posted it twice, I obviously don't get it - giving me the same response twice with no further details isn't really helpful. Not actually trying to make anyone's life difficult here. Just trying to get some help. I don't live on these boards so yeah, perhaps some further investigation is required. No need to be snarky about it.

                Trying again:

                The form:

                 
                 <form onsubmit="return validate();" method="post" name="membership_form" 
                 action=http://www.apvcalgary.com/membership_form.php><!--
                <input name="event" size="30" type="hidden" value="Membership" />
                 --><label>Membership: <select name="Event"> <option selected 
                 value=oneyear>One Year Membership with APVCS</option></select></label><label class="highlight">Legal Name: <input size="30" 
                 name=legalname> </label><label>Name that appears on Facebook (leave blank if the same): <input size="30" name="fbname"> </label><label 
                 class=highlight> Preferred Email: <input size="30" name="email"> </label><label>How did you 
                 hear about us?<input size="30" name="How_did_you_hear_about_us"> </label> Please select your payment method: <br>
                 <div class="radio_checkbox highlight padded"><input value="Yes" type="checkbox" 
                 name=Paypal[]> Paypal (you do not need a pp account to pay by credit card with them) </div> <label> Name Or Company associated with your PP account if applicable <input size="30" name="ppname"> </label> <div class="radio_checkbox padded"><input value="Yes" type="checkbox" 
                 name=EMT[]> Email Money Transfer (to apvillage@gmail.com) </div> <label> Name and email EMT will come from <input size="30" name="emtname"> </label><!--<div class="radio_checkbox highlight padded">
                 Radio Buttons:<br />
                
                 <label>yes <input name="radio_buttons" value="yes" type="radio" /></label>
                
                 <label>no <input name="radio_buttons" value="no" type="radio" /></label>
                 </div>
                
                 <div class="radio_checkbox padded">
                 Check Boxes:<br /> --><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><!--<label>yes <input name="checkboxes[]" value="yes" type="checkbox" /></label>
                
                 <label>no <input name="checkboxes[]" value="no" type="checkbox" /></label>
                 </div> 
                
                 <label class="highlight">-->
                 <div class="radio_checkbox padded"><!-- If using checkboxes be sure to include square brackets (ex. name="meal_selections[]") at the end of the name attribute --><input 
                 value=Yes type=checkbox name=Terms> I understand how <a 
                 href="#member" target=_blank> membership </a> works, and the expiration period (required for membership)</div><label 
                 class=highlight>Questions/Comments: <textarea rows="4" cols="26" name="comments"></textarea> </label>
                 <div class="submit"><input value="submit" type="submit" name="submit_button"> 
                 </div></form>
                 

                The PHP:

                 <?php
                
                 function filter($input){
                 $to_remove = array('~','`','{','}','^','[',']','<script>','</script>','<applet>','</applet>');
                 $clean = trim(str_replace($to_remove, "-", $input));
                 return $clean;
                 }
                
                 function cleanup_text_for_display($txt){
                 $txt = str_replace('_',' ',$txt);
                 $txt = ucwords($txt);
                 //$txt = str_replace(' ','&nbsp;',$txt);
                 return $txt;
                 }
                
                 if(isset($_POST) && !empty($_POST)){
                
                 $mail_content = "MEMBERSHIP FORM\r\n";
                 $mail_content .= "-------------------------------\r\n";
                 date_default_timezone_set('MST');
                 $mail_content .= date('F j, Y, g:i a')."\r\n";
                
                 $html_content = '<h2>Thank you for becoming a member!</h2>';
                
                 $html_content .= '<p>If there are any errors in the information below <a href="mailto:info@apvcalgary.com">please let us know</a>.</p>';
                
                 foreach($_POST as $key => $value){
                
                 if(is_array($value)){
                
                 $mail_content .= cleanup_text_for_display($key).': ';
                
                 foreach($value as $item){
                
                 $mail_content .= $item." ";
                
                 }
                
                 $mail_content .= "\r\n";
                
                 }else{
                
                 if($key == 'submit_button')
                 continue;
                
                 // build email content
                
                 $mail_content .= cleanup_text_for_display($key).': '.$value."\r\n";
                
                 // layout form data for display in web page
                
                 $html_content .= '<p>'.cleanup_text_for_display($key).': '.$value.'</p>';
                
                 }
                 }
                 }
                
                 //,"From:apvillage@gmail.com\r\nReply-to:apvillage@gmail.com"
                
                 if(!mail(
                 //'apvillage@gmail.com,
                 'apvillage@gmail.com',
                 'Membership Form',
                 $mail_content
                 )){
                 $html_content = '<h3>ERROR: Sorry, this message could not be sent.</h3>';
                 $html_content .= 'Please try resubmitting the form.<br /><a href="http://www.apvcalgary.com/index.html"><< BACK </a>';
                 $html_content .= '<br /><br />If this problem persists, please <a href="mailto:info@apvcalgary.com">let us know</a>. Thanks.';
                 }
                 else {
                 header("location:http://www.apvcalgary.com/form_response.html");
                 }
                
                 ?>
                
                 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
                 <html><head><title>AP Village | Calgary</title>
                 <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
                 <link 
                 rel=stylesheet type=text/css href="http://www.apvcalgary.com/styles.css">
                 <meta name="GENERATOR" content="MSHTML 8.00.6001.19170">
                
                 </head>
                 <body>
                 <div id="leftSideBar">
                 <div id="apvcImg">
                 <div id="top_text">
                 </div>
                 <div class="nav">
                 <ul>
                 <li><a href="index.html">Home </a>
                 <li><a href="about.htm">About Us</a> 
                 <li><a href="events.htm">Upcoming Events</a> 
                 <li><a href="outdoorplay.htm">Summer Playgroup </a>
                 <li><a href="indoorplay.htm">Winter Playgroup</a> 
                 <li><a href="member.htm">Become A Member</a> 
                 <li><a href="lendinglibrary.htm">Carrier Lending Library</a> 
                 <li><a href="faq.htm">FAQ</a> 
                 <li><a href="links.htm">Links</a> 
                 <li><a href="mailto:info@apvcalgary.com">Contact Us</a> </li></ul></div>
                
                 <div class="content">
                
                 <?php
                
                 echo $html_content;
                
                 ?>
                
                 </div>
                
                 </div>
                
                 <div>
                
                 <div id="footer">
                 <a href="http://www.apvcalgary.com/terms.html">Terms &amp; Conditions</a> &nbsp; &bull; &nbsp; <a href="mailto:info@apvcalgary.com">Contact Us</a>
                 </div>
                
                 </body>
                 </html></html> 
                 

                  Shame about the lack indentation, though.

                  FYI:

                  if(isset($_POST) && !empty($_POST))

                  The [man]isset[/man] test is redundant (see the description of [man]empty[/man]).

                  That said, the only way I can find for the email to be completely blank is if [font=monospace]$mail_content[/font] were empty - and the only way that could happen is if [font=monospace]$_POST[/font] is empty - because if anything was included in the submitted post, the mail would at least have the "MEMBERSHIP FORM" etc. header stuff at the top. (What's more, if the submitted form is empty, then an attempt is made to send a mail with undefined content).

                  In short, the script always attempts to send an email, and I don't see how that email could be blank sent unless [font=monospace]$_POST[/font] was empty for some reason (even if nothing was filled out, there ought to least be the submit button field). Or the server's mailer is broken.

                  So: some debugging suggestions. Instead of sending an email, have it display what it would have sent. Insert checks along the way to display things like [font=monospace]$key[/font] and [font=monospace]$value[/monospace] and compare those with what you submitted (ask your browser to show you the exact request it sent). I like using XDebug for this.

                  If [font=monospace]$mail_content[/font] is fine right up to the point where [man]mail[/man] gets called and the received mail is still completely blank, try sending a test email the same way and seeing what results:

                  $mail_content = "Are you receiving me? Over";
                  mail('address@example.com', 'Testing', $mail_content);
                  

                  If that results in a completely blank email being received by address@example.com then something is broken in your server's email setup.

                  (Incidentally, the [font=monospace]$html_content[/font] that is constructed at the same time as the mail body is wasted, because if the mail is successful, the client gets redirected to another page, and if it's unsuccessful, it's replaced by an error message. (Well, that's a simplification; the client may not automatically redirect, so the page content does get served to the client, for the benefit of users whose clients don't automatically follow redirections, but that's pretty rare in normal operation).)

                  No need to be snarky about it.

                  It's a filter: who's going to waste time helping someone who isn't capable of understanding basic instructions? Don't be that guy. (I remember one person who apparently typed with his forehead; it took eight attempts to get a coherent answer to find out that the guy wasn't even on the right site. I have less time for that these years.)

                  I don't live on these boards so yeah, perhaps some further investigation is required.

                  That's why FAQs and guidelines pages exist. Politeness would be to check stuff like that out first so you know what you're getting into.

                    Write a Reply...