...

View Full Version : Registration mail form not posting all data



joebuzz83
01-19-2010, 08:08 AM
Hi all,

I have been working on this script trying to make it work for days now, and have a deadline coming up. I am not a coder per se and cannot pinpoint the problem that is affecting this script:

<?php
if ($_POST["email"]<>'') {
$ToEmail = 'joebuzz83@gmail.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["testingheader"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY .= "First Name: ".$_POST["fname"]."<br>";
$MESSAGE_BODY .= "Last Name: ".$_POST["lname"]."<br>";
$MESSAGE_BODY .= "Address: ".$_POST["address"]."<br>";
$MESSAGE_BODY .= "Address Cont: ".$_POST["address2"]."<br>";
$MESSAGE_BODY .= "City: ".$_POST["city"]."<br>";
$MESSAGE_BODY .= "State: ".$_POST["state"]."<br>";
$MESSAGE_BODY .= "Zip: ".$_POST["zip"]."<br>";
$MESSAGE_BODY .= "Home Phone: ".$_POST["homenum"]."<br>";
$MESSAGE_BODY .= "Cell Phone: ".$_POST["cellnum"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "How did you hear about the Event? ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Your message was sent
<?php
} else {
?>
<form action="registration1.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">First name:</td>
<td width="71%"><input name="fname" type="text" id="fname" size="32"></td>
</tr>
<tr>
<td width="29%" class="bodytext">Last name:</td>
<td width="71%"><input name="lname" type="text" id="lname" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">Address:</td>
<td width="71%"><input name="address" type="text" id="address" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">Address cont.:</td>
<td width="71%"><input name="address2" type="text" id="address2" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">City:</td>
<td width="71%"><input name="city" type="text" id="city" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">State:</td>
<td width="71%"><input name="state" type="text" id="state" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">Zip:</td>
<td width="71%"><input name="zip" type="text" id="zip" size="32"></td>
</tr><tr>
<td width="29%" class="bodytext">Home Phone:</td>
<td width="71%"><input name="homenum" type="text" id="homenum" size="32"></td>
</tr>
<tr>
<td width="29%" class="bodytext">Cell Phone:</td>
<td width="71%"><input name="cellnum" type="text" id="cellnum" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>

<tr>
<td class="bodytext">How did you hear about the Event?</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
<?php
};
?>

It is only posting the cellnum, email and "How did you hear about the Event?" fields. \

I'm sorry if this has been answered many times before.

sir.jones
01-19-2010, 10:14 AM
Your code:


$MESSAGE_BODY .= "How did you hear about the Event? ".nl2br($_POST["comment"])."<br>";
Change To:


$MESSAGE_BODY .= "How did you hear about the Event? ".nl2br($_POST["comment"])."<br />";
and i advice you to change all <br> to <br />

Before PHP 4.0.5, the nl2br() function inserted <br>. After PHP 4.0.5 it inserts the XHTML compliant <br />.

Definition and Usage:

The nl2br() function inserts HTML line breaks (<br />) in front of each newline (\n) in a string.

Rowsdower!
01-19-2010, 01:35 PM
It is only posting the cellnum, email and "How did you hear about the Event?" fields. \

I'm sorry if this has been answered many times before.

Do you mean that it is literally only sending something like this:

"Cell Phone: 123-4567-8910<br>Email: address@domain.com<br>How did you hear about the Event? Method of hearing about event<br>"

Or is it sending something more like this:

First Name: <br>Last Name: <br>Address: <br>Address Cont: <br>City: <br>State: <br>Zip: <br>Home Phone: <br>Cell Phone: 123-4567-8910<br>Email: address@domain.com<br>How did you hear about the Event? Method of hearing about event<br>"

When the end product should look like this:

First Name: John<br>Last Name: Doe<br>Address: Address Line 1<br>Address Cont: Address Line 2<br>City: City<br>State: State<br>Zip: 12345<br>Home Phone: 123-456-7890<br>Cell Phone: 123-4567-8910<br>Email: address@domain.com<br>How did you hear about the Event? Method of hearing about event<br>"

tomws
01-19-2010, 01:36 PM
sir.jones: How would that fix data not showing up?

joebuzz83: Dump the $_POST variable to see what's inside. Try something like:

echo '<pre>';
print_r($_POST);
echo '</pre>';

joebuzz83
01-19-2010, 02:14 PM
Rowsdower, currently the emailed results only show:

cell number: 123456789
email: test@aaa.com
how did...event? (answer)

tomws,
do I post that code above the mail script?

Sir jones,
I added the / to all br tags.

tomws
01-19-2010, 03:07 PM
Above, below, anywhere really. It will dump the array with some visual structure. On first page load it will show an empty array. On form submit, it will show you what's actually being passed.

sir.jones
01-19-2010, 03:40 PM
OK, joebuzz83
that you mean:

First Name:
Last Name:
Address:
Address
City:
State:
Zip:
Home Phone:
not showing up? :confused:

hm... using <BR /> it just the function inserted compliant to PHP 4.0.5 +

personally, if i create the form as you like:

<?php
if ($_POST["email"]<>'') {
$ToEmail = 'joebuzz83@gmail.com\r\n';
$EmailSubject = 'Site contact form\r\n';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["testingheader"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$mailheader .= "MIME-Version: 1.0\r\n"; //<--
$MESSAGE_BODY .= "First Name: ".$_POST["fname"]."<br />";
$MESSAGE_BODY .= "Last Name: ".$_POST["lname"]."<br />";
$MESSAGE_BODY .= "Address: ".$_POST["address"]."<br />";
$MESSAGE_BODY .= "Address Cont: ".$_POST["address2"]."<br />";
$MESSAGE_BODY .= "City: ".$_POST["city"]."<br />";
$MESSAGE_BODY .= "State: ".$_POST["state"]."<br />";
$MESSAGE_BODY .= "Zip: ".$_POST["zip"]."<br />";
$MESSAGE_BODY .= "Home Phone: ".$_POST["homenum"]."<br />";
$MESSAGE_BODY .= "Cell Phone: ".$_POST["cellnum"]."<br />";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br />";
$MESSAGE_BODY .= "How did you hear about the Event? ".stripslashes($_POST["comment"])."<br />"; //<--
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
or sometimes i just change stripslashes with htmlspecialchars
Note: for sent value using $_POST["comment"], you no need to use nl2br.
Use nl2br when you call data from data...

sir.jones
01-19-2010, 04:21 PM
and also use double quote (") and single quote (') it can be effecting different result

Examples to related your case:


if ($_POST['email']<>"") {
$ToEmail = "joebuzz83@gmail.com\r\n";
$EmailSubject = "Site contact form\r\n";
$mailheader = "From: ".$_POST['email']."\r\n";
$mailheader .= "Reply-To: ".$_POST['testingheader']."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$mailheader .= "MIME-Version: 1.0\r\n"; //<--
$MESSAGE_BODY .= "First Name: ".$_POST['fname']."<br />";
$MESSAGE_BODY .= "Last Name: ".$_POST['lname']."<br />";
$MESSAGE_BODY .= "Address: ".$_POST['address']."<br />";
$MESSAGE_BODY .= "Address Cont: ".$_POST['address2']."<br />";
$MESSAGE_BODY .= "City: ".$_POST['city']."<br />";
$MESSAGE_BODY .= "State: ".$_POST['state']."<br />";
$MESSAGE_BODY .= "Zip: ".$_POST['zip']."<br />";
$MESSAGE_BODY .= "Home Phone: ".$_POST['homenum']."<br />";
$MESSAGE_BODY .= "Cell Phone: ".$_POST['cellnum']."<br />";
$MESSAGE_BODY .= "Email: ".$_POST['email']."<br />";
$MESSAGE_BODY .= "How did you hear about the Event? ".stripslashes($_POST['comment'])."<br />"; //<--
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum