PHP implementation Submission Form and output example

Source: Internet
Author: User

The topic is to do a and demo almost a meaning, give the hint should be very sufficient, including a variety of functions have.

Using this method we can save an HTML file by mentioning how to detect a commit in two ways that PHP checks whether the form is submitted.

$_post is an array (super global variable), and if the page is requested by post, the corresponding content is stored in the array.

The empty () function has been said before, and a isset () is also described later in this article

And it's basically understandable.

Source:

The code is as follows Copy Code

<! DOCTYPE html>
<meta charset= "Utf-8" >
<title> Registration System </title>
<body>
<?php
if ($_server[' Request_method ']!== ' POST ') {
?>
<form action= "form-post.php" method= "POST" >
User name: <input type= "text" name= "username" ><br/>
Password <input type= "password" name= "password" ><br/>
<input type= "checkbox" Name= "agree" > Consent License Agreement <br/>
<input type= "Submit" name= "Submission" value= "submitted" >
</form>
<?php
} else {
$problem = FALSE;
if (Empty ($_post[' username ')) {
Echo ' Please enter user name <br/> ';
$problem = TRUE;
}
if (Empty ($_post[' password ')) {
echo ' Please enter password <br/> ';
$problem = TRUE;
}
if (Empty ($_post[' agree ')) {
Echo ' You must first agree to the license agreement <br/> ';
$problem = TRUE;
}
if (! $problem) {
Echo ' Echo ' Welcome '. $_post[' username ']. ' You have successfully registered, your password is '. $_post[' password '];
}
}
?>
</body>

About

Empty () function parameter is a non-zero or Non-zero value, the empty () returns false:

"", 0, "0", Null,false,array (), var $var is considered null, and returns True if the function is empty.

True if the Isset () parameter exists, returns False if Isset () is used to test a variable that is set to NULL, or if a variable is freed using unset (), returns false.

Review: null byte ("") is not equivalent to the null function of PHP.
Note: Determine if a variable exists and is not null:!empty ($VAR)-Recommended

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.