A tutorial on passing values between PHP pages

Source: Internet
Author: User

There are many ways to pass values,
Parameter Pass value: Can be urs.php?id=1 with parameter form, this is the page compares the main transfer value way, receive value with Request,get.
From table conveys value: Main receive request pass value Post, get to receive, from tag can select Get or post through URL value is get also can use AJAX transfer value can choose Post or get.

Session Pass Value: This is usually done when the user login, server global variables, generally not in the page before the transfer value
Cookie Pass Value: Save content on client,

Our commonly used page transfer value is mainly the parameter transfer value from the table conveys value.

Now let's do a few examples.
*/
Use page parameter to pass value instance first

?>

<a href= "B.php?action=1" > Click me </a>
Output value is 1

Use form to pass values

<form action= "b.php" method= "Get" >

<input name= "Action" type= "text" value= "5" >

<input type= "Submit" value= "Submit"/>

</form>

We got a value of 5.

<form action= "b.php" method= "POST" >

<input name= "Action" type= "text" value= "5" >

<input type= "Submit" value= "Submit"/>

</form>


?
if ($_get)
{
Echo ' Get pass value ', $_get[' action '];
}
Else
{
Echo ' POST pass value ', $_post[' action '];
}
This article is original in Www.111cn.net China Web first stop, reprinted annotated Source

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.