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);

$user =m (' user ');
$res = $user->where ("User_name= ' $username ' && password= ' $password '")->find ();
if ($res)
{
Redirect ('.. /home/home ', 1, "Login successful!" page is jumping ... ");
}
Else
{
$this->error (' Login failed! ');
}
}




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
  • 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.