PHP 5.6掩盖所有$ _POST VAriables

时间:2017-05-02 18:33:59

标签: php mysql forms mysql-real-escape-string

我有一个问题。 我想通过mysql_real_escape_string掩码所有$ _POST变量(包括$ _POST数组)。脚本掩码只有$ _POST ['das']而没有$ _POST [template_id](它为空)

如何屏蔽$ _POST [template_id]?

<?php

$dbcon = mysql_connect('localhost', 'xxx', 'xxx') or 
exit(mysql_error());
mysql_select_db('xxx', $dbcon) or exit(mysql_error());

function your_filter($value) {
$newVal = trim($value);
$newVal = mysql_real_escape_string($newVal);
return $newVal;
}

foreach($_POST as $key => $value) {
$_POST[$key] = your_filter($value);
}

?>


    <form action='' method='post'>
    <input type='checkbox' class='flat' name='template_id[]' value='"2'>A<br>
    <input type='checkbox' class='flat' name='template_id[]' value='3'>B<br>
   <input type='text' class='flat' name='das' value='"test'> b<br>
   <input type='submit'>
   </form>

0 个答案:

没有答案