Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending email translates ' to \' 1

Status
Not open for further replies.

Einstein47

Programmer
Joined
Nov 29, 2001
Messages
737
Location
US
Hey all,

I have a form where I can enter a message in a textarea and when I click submit the form contents are emailed to me with the mail() function. However, in my message when I use a ' , it will show up in my email as \' .

How do I keep the backslash from showing up?

Here is a snip of my code:
Code:
    if ($mailformat == "Text")
    {
      mail($toText, $subjectText, $msgText, "To: $toText\n"."From: $fromText\n" ."X-Mailer: PHP 4.x");
    }
    if ($mailformat == "Html")
    {
      $headers  = "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      $headers .= &quot;From: Me <me@my_email.com>\r\n&quot;;

      $headers = str_replace(&quot;\r&quot;, &quot;\n&quot;,   $headers);
      $headers = str_replace(&quot;\n\n&quot;, &quot;\n&quot;, $headers);
      $headers = str_replace(&quot;\n&quot;, &quot;\r\n&quot;, $headers);

      mail($toText, $subjectText, $msgText, $headers);
    }
You see the $msgText variable is from the <TEXTAREA name=msgText> tag. What function would I need, and where exactly should I put it?

Any help would be appreciated,

Einstein47
(&quot;There are no atheists when restoring from backup.&quot;)
 
Code:
$msgtext = stripslashes($msgtext) ;



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Whenever a mail question that involves more than simple plain text messages comes up I recommend to look at PHPMailer - a class that handles mail beautifully and is stacked with options. No need to tackle RFC### ....
 
Thanks - the stripslash() was exactly what I needed.

And I'll look into PHPMailer too - thanks.

Einstein47
(&quot;There are no atheists when restoring from backup.&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top