Jump to content

mail function inserting random characters!


Stom

Recommended Posts

Hello all,

 

I'm using the PHP mail function to send the contents of an order form to both the end-user and the website owner.

 

The script i have basically loops through the submitted items and adds to a string called $order:

 

for ($x=1; $x<($_POST['element_count']+1); $x++) {
	if ($_POST['option'.$x.'qty']!=="na" && $_POST['option'.$x.'qty']!=="") {
		$order.= "<tr><td>".$x."</td><td>";
		$prod = mysql_fetch_array(mysql_query("SELECT * FROM prod WHERE id = ".substr($_POST[$x.'_prod'],-3,3)));
		$cat = mysql_fetch_array(mysql_query("SELECT * FROM cat WHERE id = ".$prod['cat']));
		$order.= $cat['name']."</td><td>".$prod['name']."</td><td>".$_POST['option'.$x.'qty']; 
	$order.="</td></tr>";
	}
}

 

This just generates a big list of items, the quantity and then i use the following to mail them off:

 

$to      = '[email protected]';
$subject = 'Website Order-form submission';
$message = $order;
$headers = 
		'From: [email protected]' . "\n".
		'Reply-To:  [email protected]'. "\n".
		'X-Mailer: PHP/' . phpversion() ."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n\n";

mail($to, $subject, $message, $headers);

 

The $order string is also then written to the page so that the user can see on the website what they have ordered. The website version appears fine, but there's something going on with the emails that are sent out. for some random reason the emails are coming through with an exclamation mark and a space inserted at random intervals (eg "Fruit Bas! kets") although always in the same place. I've checked for any odd characters that have made their way into the database and there aren't any.

 

This is driving me up the wall, does anyone have any suggestions?

 

Many thanks in advance!

Thank you for your reply drisate. Can you provide more information?

 

The odd characters only seem to appear in the parts generated by the form. I will often get several in only a few words. The rest of email displays fine.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.