NYCPHP Meetup

NYPHP.org

[nycphp-talk] Encoding text/html for mailto:

Ben Sgro (ProjectSkyLine) ben at projectskyline.com
Thu Aug 9 20:11:49 EDT 2007


Hello All, 

I've created a "Mail this section" option for a FAQ/Information Center type page I'm working on.

It enables visitors to email themselves the contents of a particular section. But I'm running into trouble
when foreign/non a-zA-Z0-9 characters are present in the code (which is being pulled from the database).


Heres' a code snippet:


            $body .= "<a href=\"mailto:?Subject=Information Center&body="
                  . html_entity_decode(strip_tags(
                    str_replace(array("&", '"', "\\"), "", $dbObject->result['body']))) . "\""
                  . " class=\"email\">Email this section</a>";

Let me reformat that, heh:
$body = "<a href=\"mailto:?Subject=Information Center&body=". $dbObject->result['body'] . "\">Email me</a>";

So, what can I use on $dbObject->result['body'] to clean/strip away the text? You can see I was messing
with a few different options..I know & will break it, as well as " ... but lets just clear out everything (HTML, and all other characters EXCEPT aA-zZ 0-9 and maybe .,-

Any help, greatly appreaciated!

- Ben
 

Ben Sgro, Chief Engineer
ProjectSkyLine - Defining New Horizons

This e-mail is confidential information intended only for the use of the individual to whom it is addressed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20070809/c4b01a3f/attachment.html>


More information about the talk mailing list