Three common methods for transferring values from PHP to different pages and passing values between php and html are as follows: phphtml_PHP tutorial

Source: Internet
Author: User
Three common methods for transferring PHP values to different pages and the issue of passing values between php and html are phphtml. There are three common methods for transferring values from PHP to different pages and the issue of transferring values between php and html. phphtml often sees the transfer of values between different pages in web work during project development, this article lists three common methods for transferring values from PHP to different pages and the issue of transferring values between php and html.

In project development, we often see the transfer of different pages in the web work. This article lists three common methods.

I have been in contact with PHP for a few months. This article summarizes three different Page passing methods that are commonly used in programming. I hope you can refer to them. I hope you can discuss any comments together.

I. POST value transfer

Post value is used for html

In form, enter the url path of the page to jump to, and in method, enter the post method. After you press the submit button in the form, all the content with name in the form will be uploaded to the filled url, which can be obtained through $ _ POST ['name']. for example:

<?php$a=$_POST['name1'];$b=$_POST['name2'];?>

Here is a handy tip. when you select "type" as "hidden" in the input tag, the input tag is hidden and not displayed on the page, but the input tag is in form, and there are name and value values, which will also be passed along with the submit button. this hidden tag can pass some content that you do not want to display.

2. GET value transfer

The GET value is transmitted by following the url. when the page jumps, the value is redirected to the url. It is often used for labels. For example:

Click to jump

After you jump to xxx. php, you can GET the passed value through $ _ GET ['id. The GET method is commonly used in URLs to delete or read php files of an id.

III. SESSION value transfer

SESSION is a type of global variables and is often used to save frequently used data such as user IDs after users log on. Once saved to the SESSION, other pages can be obtained through the SESSION. to use the SESSION, enable the session:

<? Php // session value: session_start (); $ _ SESSION ['one'] = value1; $ _ SESSION ['two'] = value2; // Read session values: $ one = $ _ SESSION ['one']; // destroy the unset of the session value ($ _ SESSION ['one']);?>

The preceding three methods are provided for your reference and I hope you will like them.

Passing values between php and html

How can I use form to pass values to php? how can php receive such data?

------ Solution ----------------------

Two parameters in the form, one action, indicates the file to which the data is transmitted. If this parameter is left blank, the default parameter is used. one method indicates the method used for data transfer. There are two types: get and post.

Add name to the input box

The accepted files are received in $ _ POST or $ _ GET. The simplest is to directly var_dump ($ _ POST) or var_dump ($ _ GET) and then you will know how to call it.

In project development, users often see the transfer value between different pages in the web work. This article will show you...

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.