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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Mr. R Posted May 1, 2007 Author Share Posted May 1, 2007 ok cheers koobi! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.