Jump to content

[SOLVED] htmlentities


Mr. R

Recommended Posts

Right.. i was looking at this and just wanted to ask a question..

 

When people register on my site i dont want them to use any characters that could be a problem, like <,>,/....

 

<?php
$str = "A 'quote' is <b>bold</b>";

// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);

?>

(Taken from PHP site)

 

so if i used this on there username and then entered this into the database then wouldn't there username be changed to something that they didnt want?

 

if they wanted to register as the name "<blah>", i want to enter "blah" into the database.

 

is there a function i can use to output their username after changing it to what is suitable, and only output the changed username if it was actually changed?

 

Thanks, hope you understand what i want to know.

 

 

 

 

Link to comment
Share on other sites

strip_tags() will strip out anything within HTML tags (unless you use the optional parameter to define a set of tags you want to allow) but you can also use str_replace() to do what you need most efficiently.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.