Php form submission example, php form example _ PHP Tutorial

Source: Internet
Author: User
Tags php form php form example
Examples of php form submission and php form submission. An example of php form submission is provided. The php form example is described in this article. a simple php form submission example is provided. the implementation steps are as follows: examples of formact php form submission and php form submission

This article shares a simple php form submission example. the specific implementation steps are as follows:

The instance code is as follows:


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.

This article shares a simple php form submission example. the implementation steps are as follows: the instance code is as follows: form act...

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