Home  >  Article  >  Backend Development  >  PHP data transfer between different pages

PHP data transfer between different pages

(*-*)浩
(*-*)浩Original
2019-10-11 11:30:592133browse

To sum up, there are four ways that I know:

PHP data transfer between different pages

1. SESSION method:

By assigning $_SESSION['name'] = value, the session value can be called throughout the session's life cycle. (Recommended learning: PHP video tutorial)

It should be noted that ‘name’ needs to be unique and cannot be repeated.

A life cycle of a session: starting from when the user accesses the page and ending when the link to the website is disconnected.

The problem with using sessions to store variables is that when a page has been opened to display seesion data before, if a new page is opened, the session-related assignments of the previous page will be updated synchronously, which is not true in some cases. desired effect. However, SESSION is therefore suitable for recording the user's online time.

2.GET method

The parameter link passed is behind the target url. What you need to pay attention to here is the two forms of url----routing form and The difference between the get value passing in path form:

The get value passing method in path form: path/index.php/?id=7878&a=234234

The get value passing method in route form: path? r=index.php?id =11&b = 88

Use $_GET on the target page to get all the get parameters

Before, I only knew the routing form, but not the path form. What does it look like, and then I am thinking about using the other three ways to pass values. Although they can all be implemented, it is a bit cumbersome. Then when I was at a loss what to do, I saw a url that was a GET value transfer method in path form.

3.POST method

form form submission action specifies the jump url;

document.formname.action = 'url';
document.formname.submit(); //formname为表单名字

4.Data table method

The most cumbersome way is to store the page content in the data table, and then retrieve specific records from the table on another page.

The above is the detailed content of PHP data transfer between different pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn