thinkphp how to pass values between different functions of different action classes
Source: Internet
Author: User
thinkphp how to pass values between different functions in different action classes
I use thinkphp to do the login page.
The landing page submits the form to action= "__app__/index/login_do", then I wrote the Login_do function in the Indexaction class:
Public Function Login_do ()
{
if ($_session[' verify '! = MD5 ($_post[' Userauthcode ']))
{
$this->error (' Verification code Error! ');
}
$username =$_post[' username '];
$password =$_post[' password '];
$password =md5 ($password);
Here is the Homeaction class:
Class Homeaction extends Action
{
Public Function Home ()
{
$this->display ();
}
}
.../tpl/home/home.html is the homepage.
Now the question is: I want to display the user name on the homepage, how can I send the value of the user name to the home.html display, the high-finger teaching, to point tips, thank you!
------Solution--------------------
Do log in when the Session is saved and then the home controller with $name=session:: Get (' name ') to obtain the user name
Then $this->assign (' name ', $name);
Output template last on template page {$name}
Speed to score
------Solution--------------------
According to the description of the #1, implemented in the __url__/top correspondence method
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.