Home>Article>Backend Development> How to jump to the page and pass value in php?
php method to jump to the page and pass the value: 1. POST value passing method, used for html [ff9c23ada1bcecdd1a0fb5d5a0f18437] form jumping method; 2. GET value passing method, jumping on the page When the user logs in, follow the url to jump; 3. SESSION value transfer method is often used to save common data such as user ID after the user logs in.
How to jump to the page and pass the value in php:
1. POST pass the value
Post value is a method used for html form jump, which is very convenient to use. For example:
The action in the form is filled in with the url path of the jump page, and the method is filled in with the post method. After the submit button in the form is pressed, all the content with name in the form will be transferred to the filled in URL, which can be obtained through <html> <form action='' method=''> <input type='text' name='name1'> <input type='hidden' name='name2' value='value'> <input type='submit' value='提交'> </form> </html>
, for example:
There is a very convenient trick here. When selecting type as 'hidden' in the input tag, the input tag will be hidden and will not be displayed on the page. However, the input tag is in the form and has a name value and The value value will also be passed along with the submit button. This hidden label can pass some content that you do not want to display.<?php $a=$_POST['name1']; $b=$_POST['name2']; ?>
GET transfer value is passed by following the url. When the page jumps, it jumps with the url. Commonly used in the use of
3499910bf9dac5ae3c52d5ede7383485tags. For example:
After jumping to<a href='delete.php?id=value'>点我跳转</a>
, you can get the passed value through$_GET['id']
. The GET method is often used in URLs to delete or read a php file with a certain ID.
SESSION is a type of global variable, which is often used to save common data such as user ID after the user logs in. Once saved to SESSION, other pages can be obtained through SESSION. To use SESSION, you need to open the session:
Related learning recommendations:PHP programming from entry to master
The above is the detailed content of How to jump to the page and pass value in php?. For more information, please follow other related articles on the PHP Chinese website!