HTML Form to PHP Email Headache
Hey folks, looking for a little guidance. I've searched the internet for php form examples and everything I try is crap. I have three forms on site each using form.php in the action line. Wen I test them, I get the email, but none of the content is being posted to the email. What am I doing wrong?
Here is my html form (my php is below that):
<form method="post" action="form2.php"><tr>
<td colspan="2"><p>
<input type="text" value="Name:" onfocus="if(this.value=='Name:'){this.value=''}" onblur="if(this.value==''){this.value='Name:'}" />
</td>
</tr>
<tr>
<td colspan="2"><p>
<input type="text" value="Email Address:" onfocus="if(this.value=='Email Address:'){this.value=''}" onblur="if(this.value==''){this.value='Email Address:'}" />
</td>
</tr>
<tr>
<td colspan="2"><p>
<input type="text" value="Address:" onfocus="if(this.value=='Address:'){this.value=''}" onblur="if(this.value==''){this.value='Address:'}" />
</td>
</tr>
<tr>
<td colspan="2"><p>
<input type="text" value="City:" onfocus="if(this.value=='City:'){this.value=''}" onblur="if(this.value==''){this.value='City:'}" />
</td>
</tr>
<tr>
<td colspan="2"><p>
<input type="text" value="State:" (ex. MI):" onfocus="if(this.value=='State:'){this.value=''}" onblur="if(this.value==''){this.value='State:'}" />
</td>
</tr>
<tr>
<td colspan="2"><p>
<input type="text" value="Zip Code:" onfocus="if(this.value=='Zip Code:'){this.value=''}" onblur="if(this.value==''){this.value='Phone:'}" /></td>
<input type="text" value="Phone:" onfocus="if(this.value=='Phone:'){this.value=''}" onblur="if(this.value==''){this.value='Phone:'}" /> </td>
</tr>
<tr>
</tr>
<tr>
<td colspan="2"><p>Areas Of Interest</td>
</tr>
<tr>
<td colspan="2"> <input type="checkbox" name="Areas of Interest" value="Fundraising" checked="checked" class="checkbox" />Fundraising
<input type="checkbox" name="Areas of Interest" value="Mentoring" class="checkbox" /> Mentoring
<input type="checkbox" name="Areas of Interest" value="Web/Graphics" class="checkbox" />Web/Graphics<br><p>
<p><input type="checkbox" name="Areas of Interest" value="Events" class="checkbox" />Events
<input type="checkbox" name="Areas of Interest" value="Administrative" class="checkbox" />Administrative
<input type="checkbox" name="Areas of Interest" value="Other" class="checkbox"/>
Other (use space below)
</tr>
<td colspan="2"><p>
<input type="text" value="Other:" onfocus="if(this.value=='Other:'){this.value=''}" onblur="if(this.value==''){this.value='Other:'}" />
</td><p>
<textarea name="textarea" cols="60" rows="5">Comments:</textarea>
<div align="left" class="col-2">
<td width="193">
<div class="link"><a href="form2.php" onclick="document.getElementById("contacts-form").submit()">submit</a></div><p></form>
</div>
PHP
<?php
$goto_after_mail = "thanks2.html";
$from_mail = $_REQUEST['from_email'];
$from_name = $_REQUEST['from_name']; // use both value's on your form
$header = "From: \"$from_mail\" <$from_name>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Mailer: Olaf's formmail version 1.10\r\n";
$header .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n";
$subject = "Please Add me to your Volunteer List" .date("m-d-Y"); //your mailsubject incl. current date
foreach ($_REQUEST as $key => $val) {
if ($key != "from_email" && $key != "from_name") { //skip, this values are already in the header
$body .= $key . " : " . $val . "\r\n";
}
}
mail("volunteer@haynesproject.org", $subject, $body, $header);
header("Location: ".$goto_after_mail);
?>
