'web developpement made easier'   




Introduction

Installation

Using templates

Using php variables

Calling a php function

The 'func' keyword

Loops

Database access

Handling conditions

Authentification

The 'func' keyword

Many websites major coding part consists in getting data from a form and applying functions to this data (usually querying a database). This treatment should generally be applied before the beginning of the next page's display.

The technique consisting in writting the code at the beggining of the file sure works but is not very elegant nor reusable easily if the websites design chages. For this purpose, bZ provides a special treatment to the 'func' variable.

Calling any php page with the 'func' variable set to a function's name value implies that the function is ran before any other treatment of the page. The function has of course to be available in the included php files of in the file itself otherwise the php interpreter will not be able to run it.

The easiest way to pass the func variable is to add it to the URL. For instance, the user logout in the authentification page "users.php" is only a link written as :


<a href="users.php?func=userLogout" >Logout</a>

The other way, to be used in forms is as a hidden value. Changing the password of a user in the "changepass.php" file bascally consists in :


<form action="users.php" >
New Password<input type="password" name="user_password" />
<input type="submit" value="Change password" />
<input type="hidden" name="user_id" value=" " />
<input type="hidden" name="func" value="chPwd" />
</form>

Since the func function is called before any display, it can be used to change the headers, a very usefull feature for page redirection.


 


Thanks to SourceForge.net Logo for hosting.       webmaster : bzsoft@free.fr