Sunday, May 29, 2011

Security PHP part(3)

Assalamualaikum and selamat sejahtera

As we already learn at previous post ,we only learn on function that just straightly print out the any special characters or code.But,unfortunately that function is not that dynamic because maybe some special characters or code,we think that it is not harmful.So,for this post we will learn a function that enable us to select any characters and this function will read the selected the characters instead of straightly print......Word is not good as i show the picture,ryte?So,below i show to you,the function that i talk about.

The function is:  strip_tags($string,tags-that-to-ignore);

So,here is the situation,we want the power up the security that we want to block any tags that might harmful such as anchor tag(<A HREF="aaa"></A>) that link to any website.But,for bold tag(<B></B>) is not a harmful tag ryte...it just bold some text.So,to make this situation happen.First,we copy first the previous code ,then find this line:

$name = $_POST['name'];
echo $name;

and change it to this:

$name = $_POST['name'];
$name = strip_tags(
$name, "<B>");
echo $name;
Run it,and type this code below inside the textbox ,then click the 'send'  button:

<B>Hye,i'm a bold text</B>

it should display right this,ryte?
 


   That all for today!!any question??just ask here

N/nOtE:So,we can unblock any tag that we want,just only one type of tag only.

No comments:

Post a Comment