[To] php three common ways to pass values between different pages

Source: Internet
Author: User

Transferred from: http://my.oschina.net/jiec/blog/196153

I. Post-pass value

The post pass value is a method for HTML <form> form jumps, which is easy to use. For example:

  

The action in the form fills in the URL path of the jump page, which is filled in with the post method. When the submit button is pressed in the form form, the contents of name in the form are uploaded to the filled URL, which can be obtained by $_post[' name ', for example:

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

  

Here is a handy tip, when the type is selected as ' hidden ' in the input tag, the input tag is hidden and not displayed on the page, but the input tag is in the form and has a name and value value, which will also follow the commit button to pass in the past. This hidden tag can pass something that you don't want to show.

Two. Get Pass value

The get value is passed by following the URL, and then the URL jumps when the page jumps. Used in the use of <a> tags. For example:

<a href= ' Delete.php?id=value ' > Point me Jump </a>

  

After jumping into xxx.php, you can get the value passed by $_get[' id '. The Get method is commonly used for URLs that are intended to delete or read a PHP file of an ID.

Three. Session Pass value

Session is a global variable, often used to save user ID and other common data after user login. Once saved to the session, the other pages can be obtained through the session, session use to open session:

<?php//session Assignment Value   session_start ();   $_session[' one ']=value1;   $_session[']=value2; SESSION value read:   $one = $_session[' one ');       SESSION Value Destruction   unset ($_session[' one ');? >

  

The above three kinds of methods are commonly used, you can refer to the use.

[To] php three common ways to pass values between different pages

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.