This is due to the PHP setting magic_quotes_gpc that you have to work with. You can use stripslashes to remove the slash, but then the code will not work if the magic_quotes_gpc parameter is turned off. Something like this will probably solve this for you:
<?php
$string = $_POST['msg'];
if(get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
?>
( magic_quotes_gpc, , , ):
<?php
if(get_magic_quotes_gpc()) {
foreach(array('_POST', '_GET', '_COOKIE') as $gpc) {
foreach($$gpc as $k => $v) {
${$gpc}[$k] = stripslashes($v);
}
}
}
?>