Tutorial  --  A short guide to using Auth_PrefManager

Setting up the database

The first step is to setup a database to store the values in. For this tutorial it's assumed that you already know the basics of using the PEAR DB class.

To set up the default table layout run the following SQL statement:

Setting and displaying default preferences

Now that we have a PrefManager object, we can make use of it to set some preferences.

For this tutorial we're going to allow users to specify their country, and assume that any user who hasn't set their country is somewhere on Earth.

First we need to set the default value, using setDefaultPref.

Now that the default is set, we can create a (very) basic page, welcoming users with a customised message.

Currently this message will only ever display "Welcome to the people of Earth!", since no users have their country set.

Full sourcecode

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.