$alerter2="false";
for ($counter = 0; $counter <= count($filter); $counter++) {
$questionsubmitted=strtolower($_POST[question]);
$currentcheck =$filter[$counter];
$foundvalue=stripos((string)$questionsubmitted,(string)$currentcheck);
echo $foundvalue;
if ($foundvalue==0) {
$alerter2="true";
} else { }
}
if (!($alerter2=="true")) {
$sql="INSERT INTO Persons (Name, Email, Question)
VALUES
('$_POST[name]','$_POST[email]','$_POST[question]')";
} else {
echo "Please only post appropriate questions";
}
由于某些原因,每当我运行这个,每次迭代stripos都会返回0。它应该是一个过滤器,并使用回声,我发现每当它出现时,stripos都是0。然而,当我在if中使用0时,即使那些没有单词的人也会返回true。奇怪的布尔反应
我应该在哪里使用mysql_real_escape_string?查询后?请注意,我将这段代码放在了我希望将用户输入保存到数据库的地方。
使用'mysql_escape_real_string();'您'$ sql'内'$ _POST'变量将是另一个事 – kjy112 2011-03-15 14:05:19
SQL注射攻击! – Arafangion 2011-03-15 14:05:54
使用字符串表示“true”和“false”。真?? – Spudley 2011-03-15 14:08:51