对于我的示例,请访问http://jflagher.mystudentsite.net/cmweb241/cmweb241_lab2.html
我只需要 htmlspecialchars 和 str_replace 函数来删除双引号和单引号。为什么这对我不起作用?我对 PHP 很陌生:/
<?php
$username = str_replace(array("'", "\""), "", htmlspecialchars($_POST['username']));
$password = str_replace(array("'", "\""), "", htmlspecialchars($_POST['password']));
$comment = str_replace(array("'", "\""), "", htmlspecialchars($_POST['comment']));
echo " <p>Your Username is: $username . </p>";
echo " <p>Your Password is: $password . </p>";
echo " <p>Your Comment was: $comment . </p>";
?>