This article mainly introduces three common methods for transferring values from PHP to different pages, as well as relevant information about the issue of transferring values between php and html, for more information about how to transfer data between different pages in project development, see the following 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.