How to install Kohana


In this guide, I will show you how you can install Kohana.



  • Kohana version



  1. Download Kohana.
  2. Create a folder on your www directory if you’re using Wamp and htdocs if you’re on Xampp.
  3. Name the folder to anything you like as long as it is easy to remember.
  4. Extract the contents of the .zip file that you downloaded earlier into the folder that you have just created.
  5. The inside of that folder should now look like this:image
  6. Open up the folder so that you will have the same screen as the screenshot above. Then open up the application folder. Then open bootstrap.php using any text editor.
  7. There are many things which you have to edit here. First is the time zone. If you’re also from the Philippines then you can use the same time zone as mine. Just use the find and replace function of the text editor to find where is this specific line of code.

Next thing, specify the folder where Kohana is installed. This will depend on the folder name you have a while ago. But mine is named kohana, and it is directly after the www directory or the root directory of the web accessible folder. So it will look like this:

    'base_url'   => '/kohana',

That’s it, you should now see this screen when you try to access the url below on your browser. Of course, the kohana here will not be the same as yours if you have named yours differently.


You might as well enable or disable some php extensions in your wamp tray icon if you want to pass all the optional tests as well.


As you can see, I failed one optional test but its okay since its just optional.


That’s how you install Kohana framework. Stay tuned. Thanks!

Simple php inventory system

This is the third part of the six part series about creating a php online store.

Here’s a summary of the

Just in case, I haven’t included the download link on the database that were going to use. Here it is. Download that and import it into any database that you have created. Using phpmyadmin.



Item Creation

This would be the form that will be used by the admin to create new products.

Go ahead and type the codes below. Or just copy and paste it into your text editor:

<form action="regprodact.php"  id="info" method="post">
   <h3>Product Registration</h3>
      <label for="prodname">Product Name:</label>
      <input type="text" id="prodname" name="prodname" class="validate[required]">
      <label for="description">Description:</label>
      <input type="text" id="description" name="description" class="validate[required]">
      <label for="reorder">Reorder Qty:</label>
      <input type="text" id="reorder" name="reorder" class="validate[required,custom[onlyNumber]]">
      <label for="bprice">Cost price:</label>
      <input type="text" id="pprice" name="pprice" value="" class="validate[required,custom[onlyNumber]]" value="">
      <label for="sprice">Unit price:</label>
      <input type="text" id="sprice" name="sprice" value="" class="validate[required,custom[onlyNumber]]" value="">
      <label for="category">Category:</label>
      <input type="text" id="category" name="category"/>
<input type="submit" value="create"/>

It’s a good practice not to make the value of the submit button into something like ‘submit’. Because that doesn’t give the user any idea on what he is doing. Most of the time you have to make use of an action word or a verb in the value of the submit button.

Next thing that you have to do is to create a new php file and name it to regprodact.php or whatever form action you have included in the item creation form. What this will do is to insert the data that is inputted by the user into the database.

<?php include('conn.php'); ?>

/* format the text*/
$inserts=mysql_query("INSERT INTO prod_table(PRODUCT, P_DESC, CATEGORY, REORDER_LVL, B_PRICE, S_PRICE") VALUES('$f_prod','$f_desc','$f_category', '$reorder', '$cost_price', '$unit_price')");
    echo mysql_error();


Item list

This will be used by the user to (surprise!) list all the items that matches the query that he is going to type in the textbox:

<form action="listprod.php" method="post">
<label for="items">Item name:</label>
<input type="text" name="items"/>
<input type="submit" value="list">

Create a new php file again, and name it to listprod.php. This is the php file that would produce the results from the user query.

<?php include('conn.php'); ?>
$list=mysql_query("SELECT * FROM prod_table WHERE PRODUCT LIKE '$item%'");
<table border="1">
<th>ITEM ID</th>
<th>COST PRICE</th>
<th>UNIT PRICE</th>
<td><?php echo $row['PID']; ?></td>
<td><?php echo $row['PRODUCT']; ?></td>
<td><?php echo $row['P_DESC']; ?></td>
<td><?php echo $row['CATEGORY']; ?></td>
<td><?php echo $row['QTYHAND']; ?></td>
<td><?php echo $row['REORDER_LVL']; ?></td>
<td><?php echo $row['B_PRICE']; ?></td>
<td><?php echo $row['S_PRICE']; ?></td>


Updating Items

This will be used by the user to update the items that are already stored in the database. You can integrate it with the list item module so that the user can search the items that he is going to update. But of course, I’ll leave that to you so that you’ll also have something to do.

Create a new php file again and name it to updateform.php. This would be use by the user to edit the existing item data that is stored on the database. I’ll leave it as a challenge on how you can connect this module with the list module.

The following are the codes for updateform.php:

<?php include('conn.php'); ?>
$listupdate=mysql_query("SELECT * FROM prod_table WHERE PID='$item_id'"); 
/*You'll have to do the rest here*/

Again, I’ll be leaving you with some challenge. The codes that are supposed to be placed after the comment is similar to the codes used for listing item data. The only difference is that it will only return 1 record. And were going to make use of textbox instead of a table. Remember that a text box should be inside a form tag, and the form tag should have 2 attributes: action and method.


Now, you have to create another php file and name it to whatever form action you have indicated in updateform.php. Here are the codes:

/*Something is missing in this part, I wonder what it is? */
/* format the text*/
$update_item=mysql_query("UPDATE prod_table SET PRODUCT='$f_prod', P_DESC='$f_desc', CATEGORY='$f_category' , QTYHAND='$qtyonhand', B_PRICE='$pprice', S_PRICE='$sprice', REORDER_LVL='$reorder' WHERE PID='$pid'");
    echo mysql_error();


Deleting Items

The last module that were going to create in this tutorial.  I’m getting lazy now, so here’s the query. Remember to do some housekeeping. This is not the full code:

DELETE FROM prod_table WHERE PID='$pid'

Changed my mind. This module should also be connected to the list item module. The most common that people do is to add a delete icon on the table that has the items listed on it. And put a link on that icon to whatever the name of the php file which performs the delete query. Add something like this to your list module:

<a href="delprod.php?itemid=<?php echo $row['PID']; ?>">

<img src="deleteicon.png"></img></a>

Common sense tells us that this link would yield a GET method. So here’s the more complete code on delprod.php or whatever you call it on the link that you have created:

$deletes=mysql_query("DELETE FROM prod_table WHERE PID='$item_id'");
/*do some housekeeping here*/

You might have notice that the parameter for the GET method should be the same as the variable that you have declared on your url. In this case it is ‘itemid’. Always remember that since the code won’t work if they are not the same.



That’s it for the inventory tutorial. Next time I’m going to tell you about the cart. The meat of this six part tutorial series.

Building an online store in php

In this series I’m going to show you how you can create an online store in php. Something like e-bay, or Amazon. But remember I’m just going to show you the basics of creating an online store. Were not actually going to create the next e-bay or amazon.


Things I won’t include

  • Pay-pal integration – I myself have no idea how to integrate pay-pal or any other third party that the clients will use to pay the items that they’re going to buy from the sites.
  • Customized products displayed for clients – We will not be tackling how to display custom products on every client page. If that’s not clear to you, I’m referring to product suggestions. For example, Customer A. Always buys blank dvd’s from the online store. I will not tackle how display the dvd’s on the client page. Something like a shortcut so that the client won’t search for the product everytime he buys from the store. Again, I won’t show you how to do that. But you can do a research and do it your self.
  • Hosting –  I absolutely won’t include this. Since I myself, don’t know how to apply for paid-hosting. And I don’t have a pay-pal account.


Modules were going to create

  • Login system – This would be used by the clients, employees, administrators to login to the system. Privileges for those users will be different from each other. There are limits to what they can do with the system.
  • Inventory- This is would be used by the administrator to determine what products need to be reordered, what products are out of quantity, etc. This also includes managing the product records, updating, deleting, and creating new products.
  • Cart – This will be used by clients to interact with the system. This is the module that they’re going to  use to buy items that are added by the administrator.
  • Purchasing-  This will be used by the administrator to add quantity to products that are below the reorder level.
  • Reports- Will be used by the administrator to gain an insight about what products are sold regularly. And what products are not sold.

On the next part of this series, I’ll discuss about the login system.

Empty mysql tables

This is a quick guide on how you can empty all of the records that is stored on a mysql table. This is useful for testing purposes, when you want to declutter the database. You can also think of different things where to use the truncate function if you’re creative.

query_database("truncate table purchase_transactions", "onstor", $link);
query_database("truncate table sales_transaction", "onstor", $link);
query_database("truncate table vendor_credit", "onstor", $link);
query_database("truncate table supplier_table ", "onstor", $link);
query_database("truncate table reports", "onstor", $link);
query_database("truncate table customer_table", "onstor", $link);
query_database("truncate table customer_credit", "onstor", $link);
query_database("truncate table categories", "onstor", $link);

That’s how you do it the long method. Here are some supplements if you want to learn how to do it in a shorter way:

Storing date and time in mysql table

In this quick guide, I’ll be showing you how you can store date and time values on mysql table using php.

First thing that you need to do is to declare your database information.

$con=mysql_connect("localhost","root","1234"); //host, user, password
mysql_select_db("onstor",$con); //database and the connection information

Then set your time zone. You can find a list of time zones that is recognized by php in this link:

I am living in the Philippines so my time zone would be declared this way:


The most important part is the value of date that you’re going to store in the database.

$date=date('Y-m-d h:i:s');

That’s the date format that is recognized by mysql. You can modify it but it might store something like this, if you don’t get it right:

0000-00-00 00:00:00

And finally, the query that will store the value into the database:

mysql_query("INSERT INTO reports(DATE) VALUES('$date')");

That’s a quick guide on storing date and time values on mysql database. Hope you learned somethingSmile

How to edit Joomla configuration file

This is just a quick guide on how you can edit the configuration file in Joomla. This is useful when you have recently changed your mysql database password. And whenever you access Joomla in your localhost, it says that it cannot connect to the database.

To edit the Joomla configuration file, just open up the folder where you have installed Joomla. Mine is in:


Then open up the configuration.php file on a text editor.


We are only interested in the final parts of the file. I’ve already commented the important parts that you may need to modify:

var $db = 'joomladb'; //this is the database where all the data used by joomla is stored
var $dbprefix = 'jos_';
var $mailer = 'mail';
var $mailfrom = '';
var $fromname = 'JoomlaTesting';
var $sendmail = '/usr/sbin/sendmail';
var $smtpauth = '0';
var $smtpsecure = 'none';
var $smtpport = '25';
var $smtpuser = '';
var $smtppass = '';
var $smtphost = 'localhost'; //host, its usually called localhost. Since the Joomla CMS is hosted on your local computer
var $MetaAuthor = '1';
var $MetaTitle = '1';
var $lifetime = '60';
var $session_handler = 'database';
var $password = '1234'; //password, this is the one that you may want to change depending on your current mysql database password.

How to use mysql stored procedures on php

I’ll try to make this short because I have already discussed some essentials on mysql stored procedures here.


  • WAMP Server
  • Heidi SQL
  • Notepad++ or any text editor with line numbers.

I’ll only be discussing how to actually call the stored procedure from your php application, so please read this first if you don’t know how to create stored procedures on heidi sql.

So in your notepad++ open up the php file where your query is.

It should look something like:

$sql="INSERT INTO students(name, course) VALUES('$name', '$course')";

Where the include part is where I inherit from the conn.php file for the mysql connection essentials. The conn.php file could look something like this:

$con=mysql_connect('$host', '$uname', '$pword' );
$sdb=mysql_select_db($con, 'databaseName');

mysql_connect and mysql_select_db are built in methods in php to connect to mysql. Often times the host name is ‘localhost’ and the username is ‘root’. There is no password by default. But I just inputted here ‘secret’ as the password.

Now, if you want to use the stored procedure that you have created. Then just call it from your php file. Just replace the actual sql query with the method call:

$sql="call stored_procedure_name('$name', '$course')";

That’s just an example, the parameters could expand depending on the fields that are on your table. Don’t forget to replace ‘stored_procedure_name’ with the actual name of the stored procedure that you have created in heidi sql.

How to activate login page on PhpMyAdmin

For those of you who are asking, how can you secure the database which can be seen on your PhpMyAdmin. Here’s how you can do it.

If you don’t know what PhpMyAdmin is, for a short intro. It is an application created through PHP which allows you to manage your MySql Database. Its automatically installed on your computer once you install Wampserver.

First thing that you’ll need to do is to launch wampserver.

Then left click on the wampserver icon on the system tray and select ‘www directory’


A new window will open up. Now, you have to go one step backward. So if you have:


Then you will have to remove the ‘www’ part. And it will look something like this:


I’m now assuming that we have the same window:


Now go to:


Remember that we may not have the same version number for phpmyadmin so its just ok if you will be seeing different number than mine.

Now open up ‘’ in that folder, and the file will have something like this:

/* Servers configuration */
$i = 0;
/* Server: localhost [1] */
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* End of servers configuration */
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

Search for this line:

$cfg['Servers'][$i]['auth_type'] = 'config';

And change the ‘config’ into ‘cookie’:

$cfg['Servers'][$i]['auth_type'] = 'cookie';

Save that, then open up phpmyadmin, and it will now look like this:


Just type in ‘root’ for the username, and the password would be none. But if you have put a password before,  then input it in there. Remember that the password in here is the same as your password in MySql Server.

If you constantly cannot login with the default username and password. Then you might want to clear the cache.

Creating new web app using yii

In this tutorial I will show you how you can create your very first web application using the yii php framework.

Yiic is the command we will be using to create the webapp.

First thing that you’ll need to do is to download the yii framework.

Then unzip it using a 7-zip, winrar, zip genius, pea zip or any other archive extracting software.

Its not necessary that you will copy the extracted folder to your web accessible folder.

But for this tutorial, just copy it there.

For those of you who are using xampp. Just copy it into your htdocs folder.

Those who use wamp, copy it into the www folder.

What we will be doing next is to add up environment variables.

To do that, just right click on My Computer->Properties->Advanced System Settings->Advanced Tab->Environment Variables


After that, focus on the system variables then scroll down until you find the first path that you will see. Highlight it and click on edit.


Now,  you need to live that window open for a while then search for the folder where you have installed php.

PHP will automatically be installed when you install either xampp or wamp.

For wamp:

-The default installation folder would be C:Wamp

then copy the  address below:


Note: The php version might be different for you, so just navigate to that folder and copy the applicable php version for you

After editing copy the address to your environment variables window. Just be sure to place a semi-colon after the last path that has been added.

As an example, mine looks like this:

C:Program FilesCommon FilesMicrosoft SharedWindows Live;
C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;
c:Program Files (x86)Microsoft SQL Server90Toolsbinn;
C:Program Files (x86)Javajdk1.6.0_18bin;
C:Program Files (x86)Javajdk1.6.0_18lib;
C:Program FilesTortoiseSVNbin;C:devsfprojectlibvendorsymfonydatabin;
C:Program Files (x86)GTK2-Runtimebin;C:Program Files (x86)AutodeskBackburner;
C:Program Files (x86)Windows LiveShared;
C:Program Files (x86)Microsoft SQL Server80ToolsBinn

Yup, that’s a bit of an overkill. If you’re wondering where did I get that one:


Finally, navigate to the directory where you copied the yii framework. Mine is in:


So I added that one to the environment variables as well. As you can see above

You can now fire up the command line. Create the directory where you will install the yii webapp. Then navigate to it


Now type in, yiic webapp [folderWhereYouWillInstallWebApp]


Type, y on your keyboard. Then bam! You will now see something like this when you navigate the directory in your browser: