PHP Form Submission example explanation, PHP form Instance explanation _php tutorial

Source: Internet
Author: User
Tags learn php php form

PHP Form Submission example explanation, PHP form instance explanation


This article for you to share a very simple PHP form submission instance, the specific implementation steps are as follows:

The instance code is as follows:

The form includes common form elements: a single-line text box, a multiline text box, a single option (radio), a Multiple-choice (checkbox), and a multiple-selection menu.

The following is a detailed description:

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 property selection element, and if an option is attached to that property, it is displayed as the first item when it is displayed.

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 display of the form above

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:

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 (Emptyempty ($_post[' username ')) {echo " You did not enter the user name "; Exit (0); } if (Emptyempty ($_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 (!emptyempty ($_post[' languages ')) {echo "The language you have selected is:";/////Handle the array of the user-selected interest checkbox button generated by foreach ($_post[' languages '] as $ Lang) {echo $lang. "";}} else {echo "You did not enter any hobbies";} if (!emptyempty ($_post[' develop_ide ')) {echo "You use the development tool as:";//Handle the array of the user's multiple-choice development Tools menu. foreach ($_p ost[' Develop_ide '] as $ide) {echo $ide. " "; } } else {echo "You did not select 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 ']. " "; } ? >

The above is for everyone to share the PHP form submission example, to help you better learn PHP form submission, I hope everyone has a harvest.

http://www.bkjia.com/PHPjc/1071230.html www.bkjia.com true http://www.bkjia.com/PHPjc/1071230.html techarticle PHP Form Submission example explanation, PHP form Instance explained this article for you to share a very simple PHP form submission instance, the implementation steps are as follows: the example code is as follows: Form Act ...

  • 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.