_php tutorial for variable transfer between two Web pages in PHP

Source: Internet
Author: User
Tags add time php and mysql php compiler
Transfer of variables between two Web pages in PHP
[Author: Bean Teeth Add Time: 2001-5-28-22:53:08]

In the website design, we often use the user login this method, after landing, the general site will be based on different users to give different pages, in the link to a new page of the station or open a new page, we will also see the user's information can be remembered, and now, especially commonly used is, After landing the link or open the site of the other pages will see such as "XXX, good evening," such as greetings, these are of course, after the landing variable transfer results, in the process of my personal homepage, have tried several variable transfer methods, is written to discuss with you.
First, this is the most stupid method, but also I did not contact the session, the cookie to come out of the method. This method is to pass the variable to be passed in the form of the way again, for example, after the user login, his information such as $username, $id and so on the information with the form sent to the next page, of course, in many cases, such as text, option and so on the box body do not want to be seen, You can take a hidden input field. Here is an example, assuming that $username is sent to this page for authentication on the page and the variable that is validated on this page, you want to pass to the next page, you can create a file test4.php:


Establish test5.php:

Open the Apache server, enter the http://127.0.0.1/test4.php button on the page to click, you will find the new page on the $username value has been sent over.
Of course, the weakness of this method is obvious, it will have to use a form again, and on the test5.php Web page want to refresh the words to resend, which is obviously not very friendly.

Second, use the session. Later, I looked up some articles about the session and thought it was a good way to pass the variables. Here is an example to illustrate:
Create a new file test6.php:
Session_register ("username"); Register a Session variable
$username = "Zhang Xiaoming"; The value of the variable to pass
echo "Go and see";
?>
Establish downloadfilesa2001-12-10est7.php:
echo "Hello, $username, Welcome to your presence!"; >//Display of variables passed over
When using this method, pay attention to: Should be placed at the front of the file, i.e. " This variable can only be passed in the currently open browser, and will be passed in the newly opened window, just as follows:
Files: test8.php
Session_register ("username");
$username = "Zhang Xiaoming";
echo "Go and see"; Pass the ID value of the current session to the next window.
?>
File downloadfilesa2001-12-10est7.php
echo "Hello, $username, Welcome to your presence!"; >
Third, through cookies. Or through an example:
Create a file test9.php
echo "Go and see";? >
File downloadfilesa2001-12-10est5.php
Establish test5.php:

The above is I in the design of the Web page and reference to some of the methods, here focus on the introduction of delivery methods, rather than the introduction of the session and the cookie, the two specific ways to use the other master has been introduced many times, I am not here swim. If I find the wrong words after the article is published, I will give a correct method in the "Comments" section below, thank you for browsing.

Related content:
-use GD to output Chinese character instances in PHP
-Acceleration of PHP application
-Construct remote services using XML technology in PHP
-PHP and MySQL build strong website
-PHP compiler option Description

http://www.bkjia.com/PHPjc/532045.html www.bkjia.com true http://www.bkjia.com/PHPjc/532045.html techarticle variable transfer between two Web pages in PHP [Author: Bean Teeth Add Time: 2001-5-28 22:53:08] in the website design, we often use the user login this method, after landing, general ...

  • Related Article

    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.