Page 1 of 1

PHP form omits message field in sumission email to me

Posted: Thu Nov 06, 2008 1:58 pm
by CJSmusic
Hi All;

First off I'm a PHP novice but its power seems great. I have an issue with my contact form. The email that is returned to me after a succesful submission seems to omit the message field. All other fields appear in the message generated.

Here is the PHP;

<?php
require_once('recaptchalib.php');
$privatekey = "..."; Omitted for security
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
die ("<meta http-equiv=\"refresh\" content=\"0;URL=recaptchaerror.html\">" . $resp->error . ")");
}

// CHANGE THE VARIABLES BELOW

$EmailFrom = $_POST['Email'];
$EmailTo = "jordan@cjsmusic.ca";
$Subject = "Contact Form Submission";

$Name = Trim(stripslashes($_POST['Name']));
$City = Trim(stripslashes($_POST['City']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=sentmessage.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

HTML as follows:

<form method="post" action="contactengine.php" id="commentForm">

<fieldset>
<legend>USE THIS FORM TO CONTACT ME.</legend>
<label for="Name">Name: *</label>
<div class="inputName">
<input type="text" name="Name" id="Name" class="required" minlength="2" /><br />
</div>
<label for="City">City: *</label>
<div class="inputCity">
<input type="text" name="City" id="City" class="required" /><br />
</div>
<label for="Email">Email: *</label>
<div class="inputEmail">
<input type="text" name="Email" id="Email" class="required email" /><br />
</div>
<label for="Message">Message: </label>
<div class="inputMesssage">
<textarea class="Message" id="Message" rows="10" maxlength="200"></textarea>
</div>
<p></p>
<div class="captcha">
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6L ... 4zpQi3OjRV">
</script>

<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=6Lc ... 4zpQi3OjRV"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
</div>
<p></p>
<div class="button">
<input type="submit" name="submit" value="Submit" id="button" />
</div>
<P>* Required Fields</P>
</fieldset>

</form>


Full HTML can be found at cjsmusic.ca/contact.html

Re: PHP form omits message field in sumission email to me

Posted: Thu Nov 06, 2008 3:15 pm
by sparrrow
Don't have a NAME defined for the message textarea object?

Code: Select all

<textarea [b][color=#FF0000]name="Message" [/color][/b]class="Message" id="Message" rows="10" maxlength="200"></textarea>

Re: PHP form omits message field in sumission email to me

Posted: Thu Nov 06, 2008 3:32 pm
by CJSmusic
Sparrow thanks for sorting through my mess of a code. You are right I forgot the <name> tag in the html.

Problem solved