A complete form processing implementation Code _php tutorial in PHP

Source: Internet
Author: User
A complete form processing
Below we will create a complex form with the code shown below.
Copy CodeThe code is as follows:


This form includes commonly used form elements: single-line text boxes, multiline text boxes, single options (radio), multiple options (checkboxes), and multiple-selection menus. The following is a detailed explanation.
MaxLength is a property associated with a password text box that restricts the maximum length of a user's input password to 10 characters.
The Age list box is a list menu that has its own values under its named properties. Selected is a specific attribute selection element that, if an option is appended with this property, is displayed as the first item in the display.
Intro the contents of the text box, displays the text, row, and column widths by rows and cols.
Fave_sport is a group of radio buttons (radio), we want to name the element by group, such as this group of radio buttons are called Fave_sport, the user can only select one, the sending script side only has a value.
As with the single option, all multi-option members must have properties with the same name, and attribute names need to be added in parentheses [], so that the value of the multi-option is sent as an array to php,languages.
The checked tag is a single option and a value in multiple options, which is already selected by default.

The above form is shown in screen 5-3.

Because the form form in the HTML above uses the Post method to pass the data, the data submitted by the user is saved to the Super Global array of $_post or $_request, and we can process the submitted data based on the values in the $_post array.

The data in the above form is submitted to the someform.php script, which has the following processing logic:
Copy CodeThe code is as follows:
By judging whether the button's variable name is defined in $_post, if there is a representation that the form has been submitted
if (Isset ($_post["Btn_submit")) {
if (Empty ($_post[' username ')) {
echo "You did not enter the user name";
Exit (0);
}
if (Empty ($_post[' password ')) {
echo "You did not enter the password:";
Exit (0);
}
echo "Your username:". $_post[' user_name '). "
";
echo "Your password (clear text):". $_post[' password '). "
";
echo "Your Age:". $_post[' ages ']. "
";
if (!empty ($_post[' languages ')) {
echo "The language you have selected is:";
Array that is generated by the checkbox button that handles user selection interest
foreach ($_post[' languages ') as $lang) {
echo $lang. "";
}
} else {
echo "You did not enter any hobbies";
}
if (!empty ($_post[' develop_ide ')) {
echo "The development tool you are using is:";
Handles the array generated by the user's multi-select development Tools menu
foreach ($_post[' develop_ide ') as $ide) {
Echo $ide. " ";
}
} else {
echo "You did not choose the development tool";
}
echo "Your Self-Introduction:". NL2BR ($_post[' intro '). "
";//nl2br (), insert the HTML line break before each new line (\ n) in the string (
)
";
echo "page hidden value (passed by hidden Tag value):". $_post[' from ']. "
";
}
?>

Description: Use post to submit the form, pass the form data through the header part of the HTTP protocol, theoretically the size of the data has no upper limit. However, when using PHP for post submission, the file size is limited by the PHP config file (php.ini), we can modify the Post_max_size parameter in the php.ini file, can change the default 2M bytes to the size we need, but due to the characteristics of the HTTP protocol, This value should not be set too large, the maximum is 8M appropriate.

http://www.bkjia.com/PHPjc/324566.html www.bkjia.com true http://www.bkjia.com/PHPjc/324566.html techarticle a complete form processing below we will create a complex form, as shown in the code below. Copy the code as follows: Form action= "someform.php" method= "post" table width= "541" Bor ...

  • Related Article

    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.