经测试代码如下:
<html>
<body>
<?PHP
/**
* 处理表单输入的特殊字符
*
* @param
* @author 编程之家 jb51.cc jb51.cc
**/
if ($_POST['submitted'] == "yes"){
$yourname = $_POST['yourname'];
$yourname = trim ($yourname);
$yourname = strip_tags ($yourname);
$yourname = htmlspecialchars ($yourname);
$yourname = addslashes ($yourname);
echo $yourname . "<br />";
?><a href="index.PHP">Try Again</a><?PHP
}
if ($_POST['submitted'] != "yes"){
?>
<form action="index.PHP" method="post">
<p>Example:</p>
<input type="hidden" name="submitted" value="yes" />
Your Name: <input type="text" name="yourname" maxlength="150" /><br />
<input type="submit" value="Submit" style="margin-top: 10px;" />
</form>
<?PHP
}
?>
</div>
</body>
</html>
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/529132.html