Upload Video Files With Codeigniter

Uploading videos using codeigniter is sometimes difficult for some people, because uploading videos need slightly different settings from other files such as .doc, .pdf, .txt. For example, we need to add support for mime which is needed for some video formats. So in this article, we will discuss how to upload a simple video with codeigniter.

Please follow the following steps in order.

  1. Make sure you have downloaded codeigniter and put it in the htdocs folder (../htdocs/ci-video).
  2. Create a folder to accommodate the uploaded files, name the folder with video in the root of your work folder. For example: htdocs/ci-video/video
  3. We need to add mime for files with .flv , .wmv, and .mp4 formats so that these video files can be uploaded with codeigniter. Therefore open the file mime.php which is in application/config/mimes.php.

Then add the following list:

‘wmv’ => array(‘video/wmv’, ‘video/x-ms-wmv’, ‘flv-application/octet-stream’, ‘application/octet-stream’),
‘mp4’ => ‘video/mp4’,
‘flv’ => array(‘video/flv’, ‘video/x-flv’, ‘flv-application/octet-stream’, ‘application/octet-stream’)

  1. Because usually the video format has a large file size, then we need to add the maximum size of the file that can be uploaded with php. For that we need to change the php.ini file, here I try to change the upload_max_filesize section to 32MB

upload_max_filesize = 32M
(the location of php.ini in each operating system is different)

Location on Xampp Windows: xampp/php/php.ini
Location on MAMP Mac : Application/MAMP/Conf/php5.x.x/php.ini

  1. Create a View with the name movie.php in (.. /Application/views/video/movie.php )


VIEW: movie.php

Display Number of Twitter Followers With PHP

There are various ways to display or find out the number of Twitter followers, using Javascript (Jquery) or PHP.

The usefulness of displaying the number of followers also varies, apart from personal statistics, displaying the number of followers is also to make others believe that the website is serious, so it is not uncommon for many people to use the services of a certain person/company to increase the number of followers (we do not will discuss that here).

Previously, tutorial-webdesign.com also discussed how to display the Twitter timeline on a website page, this trick can be combined if needed.

twitter computer
Image credit: Lakeshorebranding.com

Okay, straight to the topic, here we will use PHP to display the number of followers. Enough with just 4 lines of PHP code.

Create a file with the name twitter_followers_count.php , and fill it as follows

$twitter_id = “tut_web”;
$url = “http://twitter.com/users/show/$twitter_id”;
$response = file_get_contents ( $url );
$count = 0;
$t_profile = new SimpleXMLElement ( $response );
$count = $t_profile->followers_count;
To display it on the web page, simply print it as usual.

Difference Between Include and Require in PHP

One of the most frequently asked questions by people who are just learning PHP is, Why are there 4 ways to include a file on your web page?

There are include(), include_once(), require(), require_once()

What’s the difference? When is it used?

In this short article we will briefly know what each is used for.

Include function
The Include function is used in PHP when we want to include a file into the currently running process. It takes one argument which will be a string to the path of the file you want to include.

include “main_page.php”;
The code in the included file will be executed when the Include function is called.

It can be used in a PHP template system where you have many sections such as, header, sidebar, and footer.

include “header.php”;

include “footer.php”;
The header will be the header for the entire web page, as well as the sidebar and footer.

An error message will appear if the included file is not found.

PHP include_once Function
The Include_once function is almost the same as the Inlcude function, but will limit the files that will only be used once.

The Include function will allow you to include the same file multiple times so you can use it in a loop.

foreach($products as $product){

Will show all products

include “product.php”;
BUT, with include_once you will only display the product.php file once.

foreach($products as $product){

Will show one product

include_once “product.php”;
Another benefit of Include once is that if you define a function in the included file, it avoids redefining the function.

The Require function works like the Include function, but if the file is not found it will throw a PHP Error. This function is required for the application to work properly.

require_once “main_page.php”;
This will be a Fatal error E_COMPILE_ERROR which will stop the application from running, where the include function will only generate an error message but will not stop the application, but will continue.

The last one is the Require_once Function, which is a combination of the Require and Include_once functions. This will ensure that the file exists before adding it to the page, otherwise it will raise a Fatal Error. Plus it will ensure that the file will only be used once on the web page.

require_once “header.php”;

require_once “sidebar.php”;

require_once “footer.php”;
This function is the most restrictive of these 4 functions, and it is usually preferred in building web pages.

That’s a short article this time.
Hopefully it can be useful for you

Tutorial on making forms with Codeigniter

Dear reader. This time (in the spirit of 45) I will make a tutorial that many people still want to know. Especially for those who are new to the world of coding with the Codeigniter Framework. Yes, how to easily create forms in Codeigniter.

In essence, making the form can be created using HTML. You know for sure? But what if we want a clean and neat code written all in a file? Of course, for those of you who have been in the world of coding, of course, you always want a line of code that is fast and orderly.

Okay, basically my Codeigniter just goes to CI. Already provide a function that is collected in a file called a helper form. What are helper forms? You can see live here http://codeigniter.com/user_guide. Then how to use it? Try the following example, in this case I will create a simple registration form using Codeigniter version 2.1.3.

First create a controller, name the controller with registration.php,

Tutorial on Making Pagination in Codeigniter

Dear reader. There was a question emailed to me about how to make pagination in Codeigniter. Actually it’s easy alias easy, because Codeigniter already provides a library to do / create pages on a view data that we take from the database. Here’s how to make simple pagination my style (my own way 🙂 ).

Okay, create a database on your MySQL system, let’s say I created it with the name db_gaji.


Then create a table of employees which we will later use as the data source for our tutorial.

full_name varchar(100) NOT NULL,
jenkel enum(‘L’,’P’) DEFAULT NULL,
birth_date date NOT NULL,
gapok int(11) NOT NULL,

and fill in the employee table with the following data

After creating the table, the next step is to set the connection to our database, how to open the application/config/database.php file, on line 51 you will find the following script:

$db[‘default’][‘hostname’] = ‘localhost’;
$db[‘default’][‘username’] = ‘root’;
$db[‘default’][‘password’] = ‘admin’;
$db[‘default’][‘database’] = ‘db_salary’;
$db[‘default’][‘dbdriver’] = ‘mysql’;
Also change the file in the application/config/autoload.php directory like this:

[php]$autoload[‘libraries’] = array(‘database, pagination’);[/php]

useful for setting auto database library.

And also do a load helper to access the uri segment class to function for the pagination.

[php]$autoload[‘helper’] = array(‘url’);[/php]


After everything is ready, it’s time for us to create a model, I named it m_karyawan.php. What is its function? its function is to retrieve from the database the records that we need to display on the browser screen via files in the view directory. Make it like this:

Making Captcha in Codeigniter

Hello Web Developers .., on this holiday we will try to make a Captcha in Codeigniter, this method is the easiest way because it is very simple but very useful. Most captcha tutorials with codeigniter that I found on google, use complicated ways and are too complicated to use. Here we will try the easiest way.

Captcha Codeigniter

First, let’s get acquainted a little with Captcha.

The term “CAPTCHA” (derived from the English word “capture”) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas J. Hopper (all from Carnegie Mellon University), and John Langford (IBM). This term is an English acronym for “Completely Automated Public Turing test to tell Computers and Humans Apart”.

CAPTCHA or Captcha is a form of challenge-response test used in computing to ensure that answers are not generated by a computer.

Examples are as follows:

Example Captcha
Captcha example, source: wikipedia

Its use is usually to prevent SPAM, so to ensure that the person filling out the form is a challenge in the form of a code (captcha) that must be typed by the user (not the machine).

Captcha on Codeigniter
Okay, let’s just apply it in codeigniter.
Please note that in this tutorial we are still using pure codeigniter that has not been set before.

First create a captcha folder, its location is parallel to the system and application folders, setting CHMOD to 777 or 666.

After that create a controller named registration.php, and write the following script.

Create Login Form with PHP, Jquery & CSS3 + Download

I actually use this layout for the administrator login page for a web application project that I’m working on, after the application was finished, I finally thought of sharing it with friends at Wakaka Design. Who knows, it can be useful and help speed up the work of friends who are in need of an administrator login page design for their work.

Login Form Jquery


The design concept that will be made is minimalist and still looks modern.

What we need

We need a background with a wood texture, it can be found here.

Tutorial on Making Infinite Scroll With PHP, MySQL, Jquery

Infinite Scroll or website pages that when scrolled have no limit because they are made to automatically take (load) new data to be displayed on one page until all the data is downloaded. This infinite scroll replaces the paging function (page numbering) which we often see from the start on various websites.

Infinity Scroll

In this article, Tutorial-webdesign.com will discuss how to make a simple infinite scroll for your website, where we will try to make it in a simple gallery page.

As we know, several websites that apply this infinite scroll model are Twitter, Facebook, Pinterest, Mashable, etc.

First Step: Creating SQL Database

First we need to prepare a database, here as an example we only create one table to accommodate the names of the image files that we want to display, the database name is infinitescroll.

CREATE TABLE scroll_images (
name varchar(255) NOT NULL,
order int(11) NOT NULL,
Creating Index.php Pages

On this index.php page, we don’t really need a lot of HTML tags, if we look at it we only need to create 3 divs with different IDs, of course with a standard HTML structure, put these divs in the body.

Loading More Content

No More Content

We will display 2 images on the index.php page by placing the PHP code for the following sql query at the very top of index.php

$con = mysql_connect(“localhost”, “username”, “password”);

$result = mysql_query(“select SQL_CALC_FOUND_ROWS * from scroll_images order by id asc limit 2”);

$row_object = mysql_query(“Select Found_Rows() as rowcount”);
$row_object = mysql_fetch_object($row_object);
$actual_row_count = $row_object->rowcount;
Ajax with Jquery

Still in the index.php file, we will add Javascript / Ajax with the jquery framework to load other data after the 2 images that we load at the beginning of the website are run, this javascript script is placed in [head] and [/head], previously don’t forgot to include the jquery script which can be downloaded directly from the jquery.com website

Getting to Know Branches in PHP

All programming languages ​​have a branching function, the branching function is used to execute a command under certain conditions, there are several types of branching commonly used, namely:

if statement – ​​Used to execute some code only if a certain condition is true.
if…else statement -Used to execute some code if the condition is true and another code if the condition is false.
if…else if….else statement – ​​Used to select one of many blocks of code to be executed.
switch statement – ​​uses this statement to select one of many blocks of code to be executed
PHP branching


This statement will only execute the program block if the condition is true

if statement
If the above command is executed it will display the words “the condition is now raining”


This statement will only execute the program block if the condition is true and execute other commands if the condition is false

if else statement
if the script above is executed it will display the string “no rain” because the value of the condition variable is dry.


This statement will execute the program block with the conditions met, if the first block is not met it will check the next condition, here is an example of the syntax:

if else if else statement
If the script above is executed, it will display the string “it’s not hot and it’s not raining” because the value of the condition variable is cloudy. in the following I also make a video tutorial about branching conditions


It’s almost the same as the if else if else condition which will check every block of the program until the condition is met or execute the default syntax, the following is an example of the syntax for using the case

Tutorial How to Install Xampp on Linux Ubuntu

Linux is one of the operating systems that is widely used among developers, in addition to its free license and many open source applications that help developers work on their projects. In general, linux is divided into several distributions / linux descendants such as ubuntu, debian, open suse and others. and xampp is a webserver package that supports 3 operations, namely Windows, Linux and macOS.

How to install xampp on linux and windows is different because on linux the installation is not only with a double click but in other ways, it can be online and offline, in this tutorial we will try to use the terminal to modify access rights on the xampp file that we will install

xampp linux ubuntu

Here’s how to install xampp on linux ubuntu:

Download the latest xampp here
Open a linux terminal ( alt + t )
Grant execution access with the command sudo chmod +x filename.run
Execute the file by sudo ./filename.run and the installation process will appear
Follow the installation stages and wait until the installation process is complete
install xampp linux

If the installation is complete, the project directory is also slightly different, if on windows the directory is located in C:xampp/htdocs then on linux it is in the /opt/lampp/htdocs directory. to be able to access the project you must also give the command chmod 777 in your project folder.

If you are still confused about following the explanation above, it’s a good idea to watch the following xampp installation video on linux

so much

Hopefully this tutorial helps php developer friends who are just migrating to the linux world.