CodeIgniter 3.1 Blog example

I was recently asked to complete a coding test to create a basic blog. I decided to to use CodeIgniter 3.1 (yes – it’s not dead as was widely reported a few years ago!) as I’ve been doing a bit of work with it recently. My source code is available on BitBucket if anyone is interested… Read More »

CodeIgniter set_select default value

The CodeIgniter documentation is vague on how to set the default value in a select tag when you are using the form helper. There’s a third parameter to the set_select method that’s a boolean. I recommend using something like the following code snippet: <select class="form-control" name="email"> <option value="">None</option> <?php foreach ($emails as $option): ($option ==… Read More »

jQuery get list of form element ids as text

Here is a little JavaScript snippet to run in a browsers console – I created this to a form and lists the ids of all the form elements (so I could do things with them in PHP) var temp; $(’:input’).each(function () {temp += "’" + ($(this).attr(’id’)) + "’,"}); temp; It declares a global variable, finds all… Read More »

SQL query to alter email addresses for testing

The SQL query below can be used to change email addresses in test data so they don’t get sent to real people accidentally. The at sign in the original address is replaced with an asterisk character and then a new domain is appended to the end. UPDATE test_data SET email = CONCAT(REPLACE(email, ‘@’, ‘*’), ‘’)… Read More »

Stop postfix from sending email for testing

This applies to CentOS 6. You may want to do this when testing some code and you’re not sure if it is going to send emails or not. Edit /etc/postfix/ Add following lines at the bottom: myhostname = localhost mydomain = localdomain inet_interfaces = $myhostname, localhost mydestination = $myhostname, localhost.$mydomain, localhost mynetworks_style = host default_transport =… Read More »