parsing text for special characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've got an html form, and I have PHP parse the message variables for special characters so when I concatenate all off the message variables together, if a person has put in a ' " or other special character, it won't break it when it used in mail($to, "MMH Suggestion", "$message", "$headers"); below is my snippet of code, but is there a better way to parse the text for special characters. what about if I were to have the $message inserted into a mysql field? how would I need to handle special characters that way?

$need_message = $_POST['need_message'];

  function flash_encode($need_message)
  {
     $string = rawurlencode(utf8_encode($need_message));

     $string = str_replace("%C2%96", "-", $need_message);
     $string = str_replace("%C2%91", "%27", $need_message);
     $string = str_replace("%C2%92", "%27", $need_message);
     $string = str_replace("%C2%82", "%27", $need_message);
     $string = str_replace("%C2%93", "%22", $need_message);
     $string = str_replace("%C2%94", "%22", $need_message);
     $string = str_replace("%C2%84", "%22", $need_message);
     $string = str_replace("%C2%8B", "%C2%AB", $need_message);
     $string = str_replace("%C2%9B", "%C2%BB", $need_message);

     return $need_message;
  }

//and then there are $topic_message, $fee_message, etc and they all get concatenated with
$message .= needs_message;
$message .= $topics_message;
$message .= $fee message;

//emails the $message
mail($to, "MMH Suggestion", "$message", "$headers");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux