Page 1 of 1

Contact form excludes line breaks in message body

Posted: Mon Oct 09, 2006 8:56 am
by Leao
Hi,

I've got a contact form on my Flash website that sends its variables to the attached PHP script and consequently sends an email onto me. It all works perfectly except the email I receive always misses out the line breaks contained within the $yourmessage variable. For example if someone writes their address to me like this:
Joe Bloggs
10 Lime Avenue
London
UK


The email will present their address to me with the line breaks removed like this:
Joe Bloggs10Lime AvenueLondonUK

How can I resolve this issue?

Many thanks,

Leao

Code: Select all

<?
$to = 'mail@mydomain.org';

$subject = 'St. Patrick\'s message';

$body = "You have received a message via the St. Patrick's website. The details of the message are listed below...\n\nName: $yourname\nEmail: $youremail\nMessage: $yourmessage";

$body = wordwrap($body, 70);

$headers = "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: mail@mydomain.org\r\n";
$headers .= "Return-Path:mail@mydomain.org\r\n";
$headers .= "Reply-To: $youremail\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion()."\r\n";

mail($to, $subject, $body, $headers, "-fmail@mydomain.org.org");
?>

Posted: Mon Oct 09, 2006 9:29 am
by miro_igov
Is $yourmessage entered in some flash textbox or in <textarea> element ?

Posted: Mon Oct 09, 2006 9:30 am
by Leao
miro_igov wrote:Is $yourmessage entered in some flash textbox or in <textarea> element ?
It's entered in a Flash input text box,

Leo

Posted: Mon Oct 09, 2006 9:41 am
by miro_igov
Then try to determine what is the ascii code of the line separator for this box and replace this character with line feed '\n'

To do it you can use

Code: Select all

$strlength = strlen($yourmessage);
   $retString = "";
   for($i = 0; $i < $strlength; $i++){
       
           $retString .= $yourmessage[$i];
      
   }
  
   echo $retString;
and enter in this text box only few <enter>

Once you determine what is the ascii number for this char you can use

Code: Select all

$yourmessage = str_replace(chr($ASCIINo),'\n',$yourmessage)
where $ASCIINo will be the number you just received when echoing $retStr

Posted: Mon Oct 09, 2006 10:02 am
by Leao
Hi,

It's difficult to view the echoed results as when Flash connects to a PHP script it does so without the user being able to view the process. Is there an alternative way of doing this?

Many, many thanks,

Leo