Home > Backend Development > PHP Tutorial > PHP filters HTML and other dangerous codes submitted by forms, PHP filters form submissions_PHP tutorial

PHP filters HTML and other dangerous codes submitted by forms, PHP filters form submissions_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:15:25
Original
964 people have browsed it

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template