Php form submission example

Source: Internet
Author: User
Tags php form
This article mainly introduces php form submission instances, a simple php submission instance for beginners. For more information, see

This article mainly introduces php form submission instances, a simple php submission instance for beginners. For more information, see

This form includes common form elements: single-line text box, multi-line text box, single option (radio), multi-option (checkbox), and multi-choice menu.

The following is a detailed description:

MaxlengthIs an attribute associated with the Password text box, which limits the maximum length of a user's input password to 10 characters.

Age list boxIs the list menu, which has its own values under its naming attributes for selection. selected is a specific attribute selection element. If an option is attached with this attribute, this attribute is listed as the first item during display.

Intro text boxThe text, row, and column width are displayed according to rows and cols.

Fave_sportIs a group of radio buttons (radio). We need to name the elements by group. For example, all these radio buttons are called fave_sport. You can select only one of them, the sending script also has only one value.

Like a single option, all multi-option members must have attributes of the same name, and the attribute name must be added with brackets []. In this way, the values of multiple options are sent to PHP in an array, ages is in this form.

Checked tagIt refers to a value in a single option and multiple options. It is selected by default.

Display Screen of the above form

Because the form in the preceding HTML uses the POST method to transmit data, the data submitted by the user is saved to the super Global Array of $ _ POST or $ _ REQUEST, we can process submitted data based on the value in the $ _ POST array.

Submit the data in the preceding form to the someform. php script. The processing logic of this script is as follows:

// Determine whether the variable name of the button is defined in $ _ POST. if yes, it indicates that the form has been submitted if (isset ($ _ POST ["btn_submit"]). {if (emptyempty ($ _ POST ['username']) {echo "You have not entered the user name"; exit (0 );} if (emptyempty ($ _ POST ['Password']) {echo "You have not entered the password:"; exit (0) ;}echo "your Username :". $ _ POST ['user _ name']. ""; echo "your password (plaintext ):". $ _ POST ['Password']. ""; echo "your age :". $ _ POST ['age']. ""; if (! Emptyempty ($ _ POST ['AGES ']) {echo "the language you selected is :"; // process the array foreach ($ _ POST ['AGES '] as $ lang) {echo $ lang. "" ;}} else {echo "You have not entered any interests";} if (! Emptyempty ($ _ POST ['develop _ ide ']) {echo "your development tool is :"; // process the array foreach ($ _ POST ['develop _ ide '] as $ ide) {echo $ ide. "" ;}} else {echo "You have not selected the development tool";} echo "your self-introduction :". nl2br ($ _ POST ['intro'])."
"; // Nl2br (), insert the HTML Line Break (
) "; Echo" webpage hidden value (passed through the hidden tag value): ". $ _ POST ['from']." ";}?>

The above is an example of php form submission to help you better learn about php form submission.

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.