php

Seamlessly validate forms and file uploads with CodeIgniter

Posted by on Jul 12, 2014 in Backend | No comments

Form Validation CodeIgniter

The Form Validation class is great to validate simple input fields such as textareas, checkboxes, text fields, etc. But what about file inputs? If you have a mix of text and file inputs, your controller can get messy if you try to validate both. Lets take a look at a neat solution that only involves extending your Form Validation class.

This is how it all started

Posted by on Sep 13, 2013 in Other Stuff | 1 comment

486-dx2

In the following article I want to relate how I started in the programming and web development industry, how I learned to code and build websites from scratch. Why did I write this you may ask? So I don’t forget. Time makes you forget things. My 28th birthday was close and I wanted to keep track of my professional development so I could read about it in the future. If you have ever kept a diary, you probably know how amazing it is to read your own stories as you grow up. Life has the tendency to move things around, but writing about it is the best way to keep everything almost intact for your future self. Anyway, lets get started!

How to force a cache refresh on CSS and JavaScript files with PHP?

Posted by on Dec 30, 2012 in Backend, Frontend | 1 comment

cache-internet-explorer-ie

There is your client, complaining that they can’t see the changes you just made to their website. You explain them that they need to delete their browser cache in order to properly visualize the modifications. They said they don’t know how, and this is when you lose your patience and decide for a more radical solution. We are developers right? there has to be something easier than explaining the client how to delete their cache. Read on for more.

Mobile browser detection for WordPress – embedded is_mobile() function

Posted by on Mar 7, 2012 in Backend | 5 comments

Lets face it. Responsive design is here to stay and it is the solution to all of our nightmares regarding mobile web design. For those who are not aware of this technique, I invite you to read my other post where I explain what it is. But lets get to the point. Sometimes we need to add conditionals to our WordPress theme in order to detect if the visitor is visiting us from a mobile device, if so, we remove or add content. This is solved by using a custom made function called is_mobile() embedded into our functions.php. Read on for more.

Finding unique array combinations with PHP (permutations)

Posted by on Jun 23, 2011 in Backend | 4 comments

I was developing a website where people would place horse bets and the system should be able to calculate all the possible permutations based on the user selection. That means: finding all the possible combinations in a two dimensional array. I found a couple of functions but none of them would keep the array keys intact. So, I came up with this idea after a few gray hairs.

Error Validation Class for CodeIgniter Reactor 2.0

Posted by on May 3, 2011 in Backend | 3 comments

CodeIgniter Error Validation Class CodeIgniter lacks of an error handling class for custom errors. The Form Validation class is very nice for forms, the logs are pretty useful as well, but what happens when we need to handle our own errors?. Currently there is no official solution for this so I decided to take the matter in my own hands.

I present you the Error Validation Class.

Exporting your MySQL table data with PHPExcel + CodeIgniter

Posted by on Mar 8, 2011 in Backend | 15 comments

PHPExcel + CodeIgniter Most of the time my clients need to download data from their database tables. Exporting to CSV is a pain in the rear for users and it leads to confusion (you know the colon and semicolon stuff). Today, I decided to make a very small controller that is portable and efficient for exporting full MySQL tables to Excel 2003 using PHPExcel and CodeIgniter.

Facebook PHP SDK and CodeIgniter for basic user authentication

Posted by on Feb 24, 2011 in Backend | 206 comments


With CodeIgniter 2, plugins are no longer an option. Usually you would just add the Facebook PHP SDK as a plugin and you were good to go, but now, you need to make a little modification to the SDK in order to use Facebook Connect on your CodeIgniter application. Lets start by explaining what is, how to get started and how to authenticate an user using the Facebook API.

CodeIgniter 2.0 is out with cool features!

Posted by on Feb 13, 2011 in Backend | 4 comments

I know its a bit late, CI 2.0 has been out since January 28th, 2011, but lets talk about it anyway and recapitulate some of the new features of this framework. The new stuff is great, and this time I believe it deserves a second look if you are not much into CI.

Let me thank in advance the guys of the CI team for their great work.

Read Word documents with PHP (up to Word 2003)

Posted by on Feb 10, 2011 in Backend | 8 comments

Reading Word documents with PHP on a Linux box can be a real pain. It requires DOM which is only available on the Windows platform. However, Unkwntech from Stack Overflow made quite a nice function to read Word documents and extract its information. It will only parse text content, but it is enough for most of the tasks we will be doing anyway.

$_GET parameters on CodeIgniter

Posted by on Dec 13, 2010 in Backend | 1 comment

Yeah, it is a much discussed topic in every CI forum. I needed to set up a payment gateway and it was mandatory to receive the gateway response via $_GET, so I decided to do an investigation on the matter and this is what I came up with.

CodeIgniter 2.0 new FTP class “download” method

Posted by on Nov 25, 2010 in Backend | 3 comments

I needed to download some files from a remote FTP server and the store them in my website. The usual way would be to download all the files to my computer and then upload them to my website. In CodeIgniter 1.7.2 you would have to do this, however, the new CodeIgniter 2.0 has a new ‘download’ method that will make it real easy to transfer files between FTP servers.

Trim long texts by words in PHP

Posted by on Oct 14, 2010 in Backend | No comments


We don’t like reading chopped sentences like “Star Wars Old Republic is be….”. It looks fugly. Usually, when trimming text you will go with substr(), but there is a much better way to do it, and believe me, you trimmed text will look so much better than before.