1.11M Members

On-Line Contact Form

 
0
 

Hi
I have the following email script, which is working fine except none of the carriage returns work and the entire message from all the fields just goes in one line without any spaces.

I've tried to look up carriage returns and didn't find anything different from \r\n

Any help would be great. Many thanks

if ($_POST["contact_email"]<>'') { 
    $ToEmail = 'xxxxxxxxxxx.com'; 
    $EmailSubject = 'Mas Des Filles Contact Form'; 
    $mailheader = "From: ".$_POST["contact_name"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["contact_email"]."\r\n"; 
    $mailheader .= "Content-type: text/plain; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" .""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"]).""; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 
?> 
 
0
 

You are ending your message line and not actually including the returns:

$MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" .""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"]).""; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 

Try:

$MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" ."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"])."\r\n"; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 
 
0
 

Thank you that is great.
Now the only thing left is remover the <br /> from the email.
I thought

nl2br($_POST["contact_query"])

would solve that.

Many thanks again. Much appreciated.

 
0
 

It is all working. I just removed the nl2br.

Many thanks for all the help.

Question Answered as of 1 Year Ago by Squidge
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article