Forum Moderators: coopster

Message Too Old, No Replies

mail() is not leaving data out of the message section.

Is there a limit on leanth?

         

erikcw

11:50 pm on Aug 18, 2004 (gmt 0)

10+ Year Member



Hi All,

I just setup a script which takes 118 form entries from the user and emails the results of the questionnare to the site owner.
When the email is recieved on the other end, only questions 1-93 are included.

At first I thought it may be something with my script, but then I noticed that all 118 questions and responses are being echoed perfectly back to the user on the "confirmation page".

Does anyone know why the data is be truncated in the email?


<form action="<? echo $PHP_SELF;?>" method="POST" ENCTYPE="multipart/form-data">
<table>
<?
$i = 0;
while($i < count($item)) {

$num = $i + 1;
if($item[$i][1] == "text") { echo "<tr><td width='30%'>" . $num . ". " . $item[$i][0] . "</td><td width='70%'><input type='text' name='$i'></td></tr>"; }
else if($item[$i][1] == "textarea") { echo "<tr><td colspan='2'>" . $num . ". " . $item[$i][0] . "<br /><textarea name='$i'></textarea></td></tr>"; }
else if($item[$i][1] == "blank") { echo "<tr><td colspan='2'><br /><h3>" . $num . ". " . $item[$i][0] . "</h3></td></tr>"; }
else if($item[$i][1] == "radio") { echo "<tr><td colspan='2'>" . $num . ". " . $item[$i][0] . "<br /> <input type='radio' name='$i' value='Yes'>Yes <input type='radio' name='$i' value='No'>No</td></tr>"; }
else if($item[$i][1] == "option") { echo "<tr><td colspan='2'><br />" . $num . ". <input type='checkbox' name='$i' value='checked'>" . $item[$i][0] . "</td></tr>"; }
else if($item[$i][1] == "radio - own") { echo "<tr><td colspan='2'>" . $num . ". " . $item[$i][0] . "<br /><input type='radio' name='$i' value='Own'>Own <input type='radio' name='$i' value='Work for'>Work for <input type='radio' name='$i' value='No'>No</td></tr>"; }
else if($item[$i][1] == "image") { echo "<tr><td colspan='2'>" . $num . ". " . $item[$i][0] . "<br /><input type='hidden' name='MAX_FILE_SIZE' value='800000'><input type='hidden' name='action' value='1'><input type='FILE' name='cover' size='30'></td></tr>"; }
$i++;
}

?>
</table>
<p><input type="hidden" name="ver" value="<? echo $_GET['ver'];?>">
<input type="submit" name="submit" value="Submit"></form>

<?
} //end of version if
} else {
echo "<h3>Thank you for your submission - we will be in touch with you shortly</h3>";

// file upload processor
$uploadpath = '/home/httpd/vhosts/themms.com/httpdocs/licensing/pictures/';
$source = $HTTP_POST_FILES['cover']['tmp_name'];
$dest = '';

if ( ($source!= 'none') && ($source!= '' )) {

$imagesize = getimagesize($source);

switch ( $imagesize[2] ) {

case 0:

echo '<BR> Image is unknown <BR>';
break;

case 1:
echo '<BR> Image is a GIF <BR>';
$uniq = uniqid('img').'.gif';
$uniq = $_POST[0] . "-" . $_POST[1] . "-" . $uniq;
$dest = $uploadpath.$uniq;
break;

case 2:
echo '<BR> Image is a JPG <BR>';
$uniq = uniqid('img').'.jpg';
$uniq = $_POST[0] . "-" . $_POST[1] . "-" . $uniq;
$dest = $uploadpath.$uniq;
break;

case 3:
echo '<BR> Image is a PNG <BR>';
$uniq = uniqid('img').'.png';
$uniq = $_POST[0] . "-" . $_POST[1] . "-" . $uniq;
$dest = $uploadpath.$uniq;
break;

}

if ( $dest!= '' ) {

if ( move_uploaded_file( $source, $dest ) ) {

echo 'File successfully stored.<BR>';

} else {

echo 'File could not be stored.<BR>';

}

}

} else {

echo '<!-- File not supplied, or file too big.<BR>-->';

}
// end file upload processor
if ( $dest!= '' ) { $image = "<img src='http://www.themms.com/licensing/pictures/$uniq'>"; }

// Send form
$ver = $_POST['ver'];
/* recipients */
$to = "owner@domain.com";

/* subject */
$subject = "$ver Licensing Questionnaire";

$i = 0;
while($i < count($item)) {
$num = $i + 1;
$data .= "<p><font color='blue'>" . $num . ". " . $item[$i][0] . "</font><br /><b>" . $_POST[$i] . "</b>";
$i++;
}
echo $image;
echo "<table border='1'><tr><td><strong>Please print out your answers for your records</strong></td></tr><tr><td>$data</td></tr></table>";
/* message */
$message = "
<html>
<head>
<title>" . $subject . "</title>
</head>
<body>
<p>" . $data . "<p>" . $image . "</body>
</html>
";

/* To send HTML mail, you can set the Content-type header. */
$from = "From: $_POST[1] $_POST[0] <$_POST[11]>\n";
$from .= "X-Sender: $_POST[11]\n";
$from .= "X-Mailer: PHP\n";
$from .= "X-Priority: 3\n";
$from .= "Return-Path: $_POST[1] $_POST[0] <$_POST[11]>\n";
$from .= "Reply-To: $_POST[1] $_POST[0] <$_POST[11]>\n";
$from .= "Content-type: text/html\n";

/* and now mail it */
mail($to, $subject, $message, $from);
}

jatar_k

4:29 pm on Aug 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try using carriage returns and newlines within the message, preferably at the end of each line

There is a 2000 char limit which some isps enforce

a couple \r\n should work

erikcw

5:45 pm on Aug 19, 2004 (gmt 0)

10+ Year Member



That did the trick! Thanks!