Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Understanding the Zend Framework, Part 3: The feeds

Building the perfect reader

Tyler Anderson, Freelance Writer, Backstop Media
Tyler Anderson received his bachelor's degree in computer science in 2004 and his master's degree in electrical and computer engineering in 2005 from Brigham Young University. He worked with Stexar Corp. as a design engineer, R&D, from May 2005 to August 2006. Since his discovery by Backstop Media LLC in early 2005, he has written and coded numerous articles and tutorials for IBM developerWorks and DevX.com.

Summary:  This "Understanding the Zend Framework" series chronicles the building of an online feed reader, Chomp, while explaining the major aspects of using the recently introduced open source PHP Zend Framework. Parts 1 and 2 discuss the goals behind the Zend Framework and show you how to use it to create the beginnings of your online feed reader, creating a form and adding information to a database while getting to know the MVC pattern. In this tutorial, you will see how to use the Zend Framework to implement the online feed-reader portion of the application.

View more content in this series

Date:  18 Jan 2011 (Published 18 Jul 2006)
Level:  Intermediate PDF:  A4 and Letter (374 KB | 30 pages)Get Adobe® Reader®

Activity:  32907 views
Comments:  

Management actions

There are a couple of final management tasks that users can do to view or update their accounts and log out.

Updating an account

When a user updates an account, you can see from Listing 10 that the username is retrieved from the SESSION array, so this should not be changeable. To make it unchangeable in the register view, define it as shown in Listing 24.


Listing 24. Modifying register.php
                    
...
  <p>Username:
    <?php
       if($this->button == 'Update')
           echo $this->username .
                '<input name=\
                "username" type="hidden" value="'.
                $this->username . '">';
       else
           echo '<input name="username" value="'.
                $this->username . '">';
    ?>
...

Thus, if the user is updating his account, the username is shown, the input tag is hidden, and its value is set to the logged-in user's username. Otherwise, an empty text box is shown. The modifications can be seen in Figure 8.


Figure 8. Viewing the register view in update/view profile mode
Image shows viewing the register view in update/view profile mode

Another great example using the same view for two purposes with the Zend Framework.


Logging out

Logging out destroys the current session. Define the logoutAction method in the UserController, as shown in Listing 25.


Listing 25. Logging out
                    
    public function logoutAction()
    {
        session_destroy();
        $this->_redirect('/');
    }

This destroys the current session and sends the user back to the root. Congratulations! You're all done.

7 of 11 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=143743
TutorialTitle=Understanding the Zend Framework, Part 3: The feeds
publish-date=01182011
author1-email=tyleranderson5@yahoo.com
author1-email-cc=