Home > Backend Development > PHP Tutorial > A simple method for PHP to process special characters entered in a form, form special characters_PHP tutorial

A simple method for PHP to process special characters entered in a form, form special characters_PHP tutorial

WBOY
Release: 2016-07-12 08:59:34
Original
910 people have browsed it

How PHP simply handles special characters entered in a form, special characters in a form

This article describes an example of how PHP simply handles special characters entered in a form. Share it with everyone for your reference, the details are as follows:

<html>
<body>
  <&#63;php
   if ($_POST['submitted'] == "yes"){
    $yourname = $_POST['yourname'];
    $yourname = trim ($yourname);
    $yourname = strip_tags ($yourname);
    $yourname = htmlspecialchars ($yourname);
    $yourname = addslashes ($yourname);
    echo $yourname . "<br />";
    &#63;><a href="index.php">Try Again</a><&#63;php
   }
   if ($_POST['submitted'] != "yes"){
    &#63;>
    <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>
    <&#63;php
   }
  &#63;>
 </div>
</body>
</html>

Copy after login

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of Usage of PHP Strings", "Summary of Usage of PHP Operations and Operators", "Introduction to PHP Basic Syntax Tutorial" and "php Summary of methods to prevent SQL injection》

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • A summary of PHP’s methods of filtering and processing special characters in form submissions
  • Examples of removing left and right spaces and special characters in ltrim and rtrim in PHP
  • PHP uses the trim function to remove left and right spaces and special characters from a string. Examples
  • Old version of PHP uses a function to escape special characters in Json
  • php replaces special characters in long text Character function codes
  • PHP regular expression special characters [:alnum:] [:alpha:] etc.
  • PHP implementation code for adding a slash before special characters
  • php special character processing function

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1098688.htmlTechArticleHow to simply process special characters in form input in PHP. Form special characters. This article describes how PHP simply processes form input. Special character methods. Share it with everyone for your reference, with...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template