Php filters dangerous code such as html submitted by form submission, and php filters form submission. Php filters dangerous code such as html submitted by form submission. php filters form submission PHP filters html code that may be exploited to introduce external dangerous content. For example, sometimes php is used to filter dangerous code such as html submitted by forms, and php is used to filter form submission.
PHP filters the html code of the submitted form, which may be exploited to introduce external dangerous content. For example, some forms submitted by the user contain html content, but this may cause confusion in the layout of the display page and need to be filtered out.
Method 1:
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:
The code is as follows:
Function uhtml ($ str)
{
$ Farr = array (
"// \ S +/", // filter unnecessary spaces
// Filter scripts and other code that may introduce malicious content or maliciously change the display layout. if you do not need to insert flash, you can also addFilter
"/<(\/?) (Script | I? Frame | style | html | body | title | link | meta | \? | \ %) ([^>] *?)> /IsU ",
"/(<[^>] *) On [a-zA-Z] + \ s * = ([^>] *>)/isU ", // filter javascript on events
);
$ Tarr = array (
"",
"<\ 1 \ 2 \ 3>", // If you want to directly clear insecure labels, leave it blank.
"\ 1 \ 2 ",
);
$ Str = preg_replace ($ farr, $ tarr, $ str );
Return $ str;
}
This is a practical method. I hope it will be helpful to you.
Use PHP to filter the HTML and invalid characters of the form.
If you have not enabled the magic function, you can use the function to automatically escape it.
Use the addslashes function to escape the client data. for example:
$ Post = addslashes ($ _ POST ['value']);
At this time, the escape text is displayed!
PHP submits html forms
Your HTML code is incorrect.
... You don't need
Enclose the entire table with a button. you cannot obtain the value.
Modified HTML code:
</Td> </Tr>
|
Your message: </font> </td>
|
</Textarea> </td> </Tr>
|
</Td> </Tr>
|
Contact Info:
QQ or email </font> </p> |
</Td> </Tr>
|
</Td> </Tr>
|
</Td>
|
PHP filters the html code of the submitted form, which may be exploited to introduce external dangerous content. For example, you may use... |