PHP archive

I have been working with the PHP language since early 2001, first as the nerdy hobby of a spotty teen and then later into my career as a Web Developer. I try to write about PHP things that will be useful to me, useful to you, and everything in between.

Mail Form Subscriptions

PHP Mail Form – Moved

A few folks seem to have missed my waffling about it on twitter, snark etc so consider this the ‘official’ announcement that my simple PHP mail form has moved to jem’s mail form .com

Project: Feeding Friendly

While I was on maternity leave in 2009-2010 I had an idea for a website / mobile phone app… a central location for feeding and changing facility reviews/ratings across the UK. There was nothing else like it available, and parents (especially breastfeeding mums I came into contact with) were desperate for accurate info on things like comfy, clean nursing rooms; bottle-warmers or boiled water available; changing facilities that actually had mats or decent tables and not just filthy plastic racks hanging from the wall.

Anyway, I finally started building the site this week. I’ve decided to build on the fly – completely live – instead of doing it offline and perfecting it (because I’ve discovered this means projects never get finished!) The plan is to use a WordPress back-end so that I can bum off their functioning user management as well as using custom content types to power the tagged locations and reviews. Nothing actually works at the minute and there is no design – hey, I’m juggling a toddler and a full time job here – but I want to get feedback now. Lo, Feeding :)

If you’re interesting in contributing to the project … ideas, reviews, suggestions, whatever, please let me know. I will especially need mums who go out and about a lot to work with me tagging & rating places to begin with, so we can get some bare bones data up there. Comment here or e-mail me:

Mail Form V2.2

In anticipation of the release of my mail form as a plugin for WordPress, I have updated the standalone mail form script.

Updates as follows:

  • compressed and optimised badword checking; checking name field too
  • more easily customisable required fields
  • added more known bots to isBots() function
  • disable Send button on successful mail send to help prevent spam
  • removed carriage return char from header to prevent bad header errors in gmail

As usual, although extensive checking and bug testing has occurred, it’s up to you to let me know if I’ve missed anything. Do leave a comment or fire me an e-mail if you come across any problems.

More WordPress Goodies

I’ve been getting about a bit lately — no sarcastic comments please — so thought I’d share the results of my hard work. More WordPress stuff:

Have also got a spin-off of the shortcode tutorial in the works which will enable folks to write their own basic Formspring plugin (to display answered questions on your WP blog). Keep your eyes peeled…

Handy WordPress Dev Stuff

I recently mentioned some bespoke WordPress plugin development I was doing for a work client; I have a few links I saved at the time which helped me build in styles using built-in WordPress classes, as well as functions / hooks / etc which made my life easier. I thought they may be of use to fellow devs so thought I’d share:

As I find the notes I scribbled these URLs down in, I’ll add to this post.

One thing I did note, however, is that some of the guides etc I came across were using deprecated WP functions. (Obligatory disclaimer…) it’s definitely worth getting to grips with the codex, and checking pages for hooks that you’re unfamiliar with before blindly copy-pasting someone else’s code (not to mention the possibility for security holes, yadda yadda).

Mail Form V2.1.2

Version 2.1.2 of my mail form has now been released, fixing the bug preventing spaces in the name field.


To keep me on the ball while I was enjoying my extended maternity leave last year, I volunteered my services to Mumsnet regular and owner/blogger ‘Aitch’. Aitch was fed up of being unable to update her existing website, based on a Joomla backend, and had not blogged in several years. The site was falling into disrepair and visitor traffic was being wasted.

I suggested WordPress to Aitch as a user-friendly and easily extendible content management system. Following a nod of approval, the original blog data was imported and the pages built around original Joomla content. I converted the site style to a WordPress theme, built features into bespoke widgets and linked all of the pages together.

Following an early new year release, I agreed to get BabyLedWeaning ‘out there’ and so began creating a social media profile on Twitter and Facebook. The site’s popularity did the rest of the work for me and within 24 hours of release, the Twitter/Facebook followers were in triple figures!

Going forward, I plan on creating and integrating a custom plugin to allow regulars to submit and update their own recipes which should boost the content and pull in visitors from outside of the current site niche. Working with Aitch and the baby led weaning site has been a pleasure, long may it continue…

WordPress Plugin Development

Although I’ve used WordPress on and off for years, the closest I usually get to plugin development is custom widgets. This is not through lack of willing, but rather that everything I’ve wanted is already out there and I’m too lazy busy to reinvent the wheel.

However, one of our work clients has put in a request for an interesting addition to their site which is currently not really satisfied by any decent/up-to-date plugins. Part of the project involves extending the user-side of WordPress with full profiles, account history etc. It’s very “web 2.0” (now there’s a buzzword I’ve not heard in a while).

The advantage of this, beyond increasing my WordPress knowledge and experience, is that it’s given me the inspiration/kick up the arse needed to turn my free PHP mail form into a WordPress plugin!

PHP Mail Form Updated

Version 2.1 of my basic free PHP mail form is now live; this has been ‘ported over from my personal domain ( in an attempt to organise my content (and life!) a little better.

Please feel free to get in touch with feedback.

First PHP Game

Remember when I talked about wanting to code some PHP games? (Yes, it was in 2008, what’s your point?) Well I finally managed to fit one in to my busy schedule last week, whilst avoiding studying for my current OU module.

Ignoring the fact that it’s talking about points (only relevant for the final ‘install’) and that there’s no graphics yet, feel free to have a play… Higher or Lower

If you manage to break it, let me know. I’d share the code but as it’s the first thing I’ve coded in months I’m not feeling particularly brave. :P

WordPress Child Pages Page… or something

OK, back to srs business posts now…

One of my current top secret projects (it’s not that exciting, I’m just helping someone convert their site to WordPress) involves creating pages with a list of child pages on ’em. Back in ye olde days I’d have done this manually (which meant every time a child page was added the parent had to be modified) or farted about with SQL queries but Modern Day WordPress seems to have a function for everything and so it’s much simpler. So, without further ado…

Create the template:

Template Name: Sub Page

<?php get_header(); ?>

<div id="content">

	<h2><?php the_title(); ?></h2>

	$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
	if ($children) {
			<?php echo $children; ?>

	if ($post->post_parent)
		echo '<a href="'. get_permalink($post->post_parent) .'">&laquo; Back to '. get_the_title($post->post_parent) .'</a>';


<?php get_sidebar(); ?>

<?php get_footer(); ?>

Save it as subpage.php, upload it to your theme directory and then whenever you just want a list of sub (child) pages, select Sub Page from the Template dropdown on the right. Ner nerrr!

Tip: if you wanted a section intro instead of just a list of links, bung <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); ?><?php the_content(); ?><?php } } ?> after the h2 title stuff.