我必须创建一个登录表单,用户需要输入用户名和密码。我必须确保不处理html实体,并且也不能处理单引号或双引号。我必须回显表单中输入的数据并显示它。
我必须使用 htmlentities 和 str_replace 函数。我已经正确地使用了 htmlentities 函数,但是不确定如何使用 str_replace 函数来替换用户可能输入到表单中的单引号和双引号。任何帮助都将非常棒。
以下是我的当前PHP代码(有效):
我必须使用 htmlentities 和 str_replace 函数。我已经正确地使用了 htmlentities 函数,但是不确定如何使用 str_replace 函数来替换用户可能输入到表单中的单引号和双引号。任何帮助都将非常棒。
以下是我的当前PHP代码(有效):
<?php
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$comment = htmlspecialchars($_POST['comment']);
?>
<html>
<body>
Your username is: <?php echo $username; ?><br />
Your password: <?php echo $password; ?><br />
Your Comment was: <?php echo $comment; ?>
str_function
。到目前为止,这只让我头痛(因为我非常新手PHP)。 - Jeremy Flaugher