这篇文章主要介绍了PHP如何处理表单输入的特殊字符,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
具体如下:
<html>
<body>
<?php
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" />
</form>
<?php
}
?>
</div>
</body>
</html>
感谢你能够认真阅读完这篇文章,希望小编分享的“PHP如何处理表单输入的特殊字符”这篇文章对大家有帮助,同时也希望大家多多支持天达云,关注天达云行业资讯频道,更多相关知识等着你来学习!