Page 1 of 1

echo returns "\" instead of "'"

Posted: Sun Nov 16, 2003 1:08 am
by r3curse
I make use of a contact form on my (future) site, and when the user hits submit, I use echo to output the message sent to my email, but, whenever there's a word with a "'" in it (can't, don't etc..) php echoes it as a "\", so instead it looks like this: don\t, can\t etc..

how do I work around that?

-----------------------------------
<?php $to = "you@me.not";

$message = $message;

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

echo("<strong>THANK YOU!</strong>
<br>The following message was sent:
<br><br><strong>to:</strong><br>
<a href=\"http://www.notyet.no\" class=\"nonbold\">notyet.no</a><br><br>
<strong>message:</strong><br>
$message\n");?>
-----------------------------------

I'm not a stable coder, so don't make fun of my php-code :)

Any help would be greatly appreciated!
Thank!

Best retards,
r3curse

Posted: Sun Nov 16, 2003 4:34 am
by Nay

Code: Select all

<?php

$to = "you@me.not";

$message = $_POST['message']; // i'm sure it came from a form
$message = str_replace("", "'", $message);

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

echo <<< HERE
   <strong>
      THANK YOU!
   </strong>

   <br />
      The following message was sent:

   <br /><br />

   <strong>
      to:
   </strong>

   <br />

   <a href="http://www.notyet.no" class="nonbold">
      notyet.no
   </a>

   <br /><br />

   <strong>
      message:
   </strong>

   <br />

      $message

HERE;

?>
Not 100% sure but that might work,

-Nay

Posted: Sun Nov 16, 2003 5:54 am
by r3curse
well, almost :)
it returns the following:

don''t etc

hehe

Posted: Sun Nov 16, 2003 5:55 am
by qads
stripslashes(); is what you need to use :) .

Posted: Sun Nov 16, 2003 6:21 am
by r3curse
uh, like this I guess:

Code: Select all

$message = stripslashes($message);
:)

Posted: Sun Nov 16, 2003 6:23 am
by r3curse
yay!

thanks a bunch, qads :)

Posted: Sun Nov 16, 2003 7:07 am
by qads
i am surprised Nay didnt tell you that, what you been smoking Nay? :lol:

Posted: Sun Nov 16, 2003 8:08 am
by Nay
your stuff O_O...............you sold me the wrong stuff dude

-Nay

Posted: Sun Nov 16, 2003 8:35 am
by qads
lol, you should've known it was just plain old, dried up grass!

Posted: Sun Nov 16, 2003 10:37 am
by r3curse
anyways... thanks :)