php filters html and other dangerous codes submitted by forms, php filters form submissions
The html code of the PHP filter submission form may contain code that can be exploited to introduce external dangerous content. For example, sometimes the user submission form contains HTML content, but this may cause confusion in the display page layout and needs to be filtered out.
Method 1:
Copy code The code is as follows:
//get post data
function PostGet($str,$post=0)
{
empty($str)?die('para is null'.$str.'!'):'';
if( $post )
{
If( get_magic_quotes_gpc() )
{
Return htmlspecialchars(isset($_POST[$str])?$_POST
[$str]:'');
}
else
{
Return addslashes(htmlspecialchars(isset($_POST[$str])?
$_POST[$str]:''));
}
}
else
{
If( get_magic_quotes_gpc() )
{
Return htmlspecialchars(isset($_GET[$str])?$_GET[$str]:'');
}
else
{
Return addslashes(htmlspecialchars(isset($_GET[$str])?
$_GET[$str]:''));
}
}
}
Method 2:
Copy code The code is as follows:
function uhtml($str)
{
$farr = array(
"/s+/", //Filter excess blanks
//Filter