PHP Form Not Posting 2 Fields

When the e-mail comes in it’s only posting from “acct” down and is completely excluding the “first” & “last” fields. I have stared at it for hours to figure out what could possibly be the problem but am now freaking out! Here’s my html form:

    [code]<form action="debtor_contact.php" method="post" name="ContactForm" onsubmit="return ValidateContactForm();" class="customClass2">
      <p>Your Name <font color="red">*</font> <br/>
        <input name="first" type="text" size="15" maxlength="30" value="First" />
        <img src="../images/trans_gif.gif" height="1" width="5" />
        <input name="last" type="text" size="15" maxlength="30" value="Last" />
      </p>
      <p>RTC Account # <br/>
        <input name="acct" type="text" size="9" maxlength="9" />
      </p>
      <p>E-mail <font color="red">*</font> <br/>
        <input name="email" type="text" size="30" maxlength="50" />
      </p>
      <p>Comment <font color="red">*</font> <br/>
        (Adjust the text box size by dragging the lower-right corner) <br/>
        <textarea name="comment" cols="50" rows="5"></textarea>
      </p>
      <input name="submit" type="submit" value="Submit" />
    </form>[/code]

Here’s my php:

[php]<?php
$field_first = $_POST[‘first’];
$field_last = $_POST[‘last’];
$field_acct = $_POST[‘acct’];
$field_email = $_POST[‘email’];
$field_message = $_POST[‘comment’];

$mail_to = ‘redacted’;
$subject = ‘Site Contact from Debtor’;

$body_message = 'First Name: '.$field_first."\n";
$body_message = 'Last Name: '.$field_last."\n";
$body_message = 'Account #: '.$field_acct."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>

<?php } else { ?>
<script language="javascript" type="text/javascript">
	alert('Message failed. Please, use one of our other contact methods.');
	window.location = 'contact.html';
</script>
<?php } ?>[/php]

Here’s the javascript validator:

[code][/code]

Save me!! :o

Look here:

[php]
$body_message = 'First Name: '.$field_first."\n";
$body_message = 'Last Name: '.$field_last."\n";
$body_message = 'Account #: '.$field_acct."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
[/php]

The .= means to append to an existing string. If you are missing the . before = then you are overwriting the existing string. I believe you wanted:

[php]
$body_message = 'First Name: '.$field_first."\n";
$body_message .= 'Last Name: '.$field_last."\n";
$body_message .= 'Account #: '.$field_acct."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service