Mr. R Posted May 1, 2007 Share Posted May 1, 2007 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 https://forums.phpfreaks.com/topic/49519-solved-htmlentities/ Share on other sites More sharing options...
jcombs_31 Posted May 1, 2007 Share Posted May 1, 2007 htmlentities should be used to display the html, not to strip out characters. Link to comment https://forums.phpfreaks.com/topic/49519-solved-htmlentities/#findComment-242703 Share on other sites More sharing options...
Mr. R Posted May 1, 2007 Author Share Posted May 1, 2007 Ok thanks . How would i go about stripping out characters then? then displaying their username after doing so? thanks Link to comment https://forums.phpfreaks.com/topic/49519-solved-htmlentities/#findComment-242711 Share on other sites More sharing options...
Koobi Posted May 1, 2007 Share Posted May 1, 2007 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 https://forums.phpfreaks.com/topic/49519-solved-htmlentities/#findComment-242773 Share on other sites More sharing options...
Mr. R Posted May 1, 2007 Author Share Posted May 1, 2007 ok cheers koobi! Link to comment https://forums.phpfreaks.com/topic/49519-solved-htmlentities/#findComment-242783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.