Jump to content
MakeWebGames

Recommended Posts

Posted

Hello i am wondering, if htmlentities and htmlspecialchars are the same thing.

If they are not the same thing, what does htmlentities do?

I have seen a code like this

$_POST['post'] = mysql_real_escape_string(htmlentities($_POST['post']));

so if htmlentities and htmlspecialchars are not the same thing how would i put htmlspecialchars in the code above? woluld it be like this?

$_POST['post'] = mysql_real_escape_string(htmlspecialchars($_POST['post']));

I will appreciate it if anyone can help me :P

Thanks

Mr Moon

Posted

they arent the same but very similar

htmlentities — Convert all applicable characters to HTML entities

htmlspecialchars — Convert special characters to HTML entities

there is no need to use both, if you want everything html not to go through a post then you would use htmlentites.

If you only want special characters not to go through then you use the other one htmlespecialchars... using both is useless imo. lol.

and yes you have the correct way of placing the function!

Posted

Oh thanks i am kinda understanding it now

Well this is what htmlspecialchars secured:

I think it secures your site from HTML injection and some XSS attacks

So does htmlentitles do the same thing or does it also secure from all xss attacks?

Also what do you mean if i dont want special characters to go through like what kinda character and which would be the best to use for Mccodes v2 htmlspecialchars or htmlentitles?

Thanks Mr moon :P

Posted

I really don't get this... why is the title mccodes security yet your not posting anything from MCC... php.net explains functions ;)

Also if you really wanna filter then why not use preg?

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.   Paste as plain text instead

  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...