/    Sign up×
Community /Pin to ProfileBookmark

Processing Text

I need something to process some text entered in a form field by a user, so that I can just plonk it into a php generated email. The basic idea is to pre-process the text, eliminating anything the user might have entered that could cause a problem with the email. I mean it does not have to be great. I suppose eliminate everything other than a-z, 0-9 spaces, commas and a few other things. Anyoen got anything handy?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 18.2006 — Is the email being output as HTML or plain text?
Copy linkTweet thisAlerts:
@DurothFeb 18.2006 — You might want to check out http://nl3.php.net/manual/en/function.htmlspecialchars.php for this one.

The function would probably be like this:

[code=php]$var = htmlspecialchars("$var", ENT_QUOTES);[/code]

This converts all HTML to textual chars, meaning that using scripts and HTML is nearly impossible.

Edit: http://nl3.php.net/manual/en/function.htmlentities.php might do an even better job:
[code=php]$var = htmlentities("$var", ENT_QUOTES);[/code]
×

Success!

Help @SuzanneB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...