>  기사  >  백엔드 개발  >  PHP가 양식에 입력된 특수 문자를 처리하는 간단한 방법

PHP가 양식에 입력된 특수 문자를 처리하는 간단한 방법

巴扎黑
巴扎黑원래의
2016-11-21 10:36:28988검색

이 기사의 예에서는 PHP가 양식에 입력된 특수 문자를 어떻게 처리하는지 설명합니다. 참고하실 수 있도록 모든 사람과 공유하세요. 자세한 내용은 다음과 같습니다.

<html> 
<body> 
<?php 
if ($_POST[&#39;submitted&#39;] == "yes"){ 
$yourname = $_POST[&#39;yourname&#39;]; 
$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[&#39;submitted&#39;] != "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>


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.