PHPMaker Tutorial
PHPMaker Tutorial
understanding of the generated code. The menu, for example, is on the left by default which
you cannot change through PHPMaker, but you can manually edit the generated code and
position the menu to the top.
Well be making a simple web application for a library. Members will be able to search the
library catalogue and list books by categories. Staffs will be able to add/edit/remove books as
well as register/deregister members.
You will need XAMPP to try out the app.
You must create a database with your tables first. Open phpMyAdmin and write out your
MySQL statements. In our case we need to create two tables:
CREATE TABLE books (
book_idint(8) primary key auto_increment,
titlevarchar(50) not null,
authorvarchar(50) not null,
covervarchar(100)
)
CREATE TABLE users (
user_idint(8) primary key auto_increment,
usernamevarchar(20) not null,
passwordvarchar(20) not null,
user_levelint(2) default 0,
loanedint(8) references books(id)
)
Every time youre working on PHPMaker, youll need to have XAMPP running.
Open PHPMaker and connect to the database.
Normally, the username should be root and the password field should be left empty. You can
always change that through phpMyAdmin for extra security. When you click on the Connect
button, you should see your two tables appear in the left panel.
User Login
Since, our app will require login, we need to set this up. Head over to the security tab.
Remember that members details will be stored in the users table. PHPMaker needs to know
that along with the names of columns for the username and password.
We are not done yet. We need to click on the Advanced button to set up additional user login
options.
The settings are self-explanatory. You might not check all of them, but user registration should
at least be enabled. Well come back to this later when well have to set permissions on who
can or cannot view/edit table and views.
Generating
Before generating the app, ensure that XAMPP is running. Set the application root folder to that
of XAMPP www folder. If you want PHPMaker to automatically open your browser after
generation, set the following option:
After generation, you will be presented with a login screen. You might not see the tables now
as you have not yet set permissions for user levels.
Crime
Fantasy
Humor
Horror
Travel
Right-click on the View option is the left panel, and select Create View from the context menu.
We need to write SQL statements for each view. Here the view will consist of all crime books.
Dont forget to give it a name. Repeat the same procedure of the other categories.
In the end, well obtain this:
PHPMaker lets you specify what kind of html tags each column of a table/view is generated
into. Since each book has a cover, we need to provide image upload/preview functionality.
Set an upload folder from the PHP tabbed menu:
Change the View tag to IMG and the Edit tag to file as follows:
What this does is display the cover when the table books is listed. Do the same for the views.
Setting permissions
Obviously, a normal user should not be allowed to do edit/add operations on some tables. If
you remember, theres a user_level column in table users. By default,we made it zero.
PHPMaker has two built-in user levels (you can more): -1 and 0.
-1 is for administrator. 0 is the default. When a user registers, hes assigned 0 by default. Staff
will have their user level upgraded to -1 by the database administrator.
Here we have set list/search/view permissions for members.
PHPMaker always generates a blank page named blankpage.php. Since youve entered the Start page
as being home.php, you must rename blankpage.php to home.php so PHPMaker can find and open it
the next time. If you make some changes to your project and generate again, your home.php will not be
overwritten. Look for it in the destination folder.
10