[PHP] Forms and validation

Source: Internet
Author: User

<?php/* forms: Publishing and gathering information through forms.  Encoding an HTML form is only necessary to effectively accept user input (part), a header function (header ()) header (header) must be handled by the [Server side] Component: The server passes HTML data from the HTTP protocol to the browser between [header] and [HTML file]  Requires a blank line to separate. The header () function is used to send an original HTTP header. A void header (string string [, bool replace [, int http_response_code]]) header can be in two forms: 1. Redirect the specified URL header (' Location:ht Tp://www.baidu.com ');      2. Set page character encoding header (' content-type:text/html; Charset=utf-8 '); [note] Unless {output buffering} is enabled, these commands must be placed before statements that return any output.      (Just put it at the beginning of the file) enable output buffering: Ob_start (); Accept data using $_post and $_get: 1. The form method sent by $_get[' username ' must be get;2. The form method sent by $_post[' username ' must be post;3. Use Isset () to verify that the $_get[' username '] Super global variable is defined; 4.   Use Htmlspecialchars () to filter HTML special characters. Validation of {Data validation}: 1. Trim () Remove the front and back space of the data; 2. Strlen () Determine the length of the data; 3. Is_nuimeric () to determine whether the data is purely numeric; 4.    Use {Regular expression} to verify that the mailbox is legitimate. *//*if (!isset ($_post[' send ')) | | $_post[' send ']!= ' commit ') {header (' Location:demo1.php '); exit;} Else{echo "

  

[PHP] Forms and validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.