Archive for the 'CakePHP' Category


Session-Based Flash Messages Look Better (CakePHP)

The CakePHP blog tutorial uses a rather archaic method of displaying user messages (like, “Your post has been saved.“) that needlessly breaks up the flow of your application. Rather than Cake’s typical method of displaying flash messages on a separate page (ugly), learn how to seamlessly display the same messages within your application and make your users clap with joy.

Read more »

CakePHP 1.1 File Upload Plays Rough With PHP 4

Uploading files via CakePHP has been covered a few times on Labs. Based on the feedback, it’s safe to assume bridging the gap between file uploads and PHP can be tricky. Usually Cake is ready to lend a helpful hand. Not this time.

Read more »

A Simple/Secure Email Class For PHPMailer

If you’re not careful, sending email via PHP is about as safe as cookies at Fat Camp. BKWLD was recently tagged by a spammer who noticed one such insecurity on one of our websites and ended up using our server to send hundreds of emails. It wasn’t until MediaTemple informed us of this breach that we realized what had happened.

The method most spammers use is called a “mail injection”, in that the spammer manipulats the PHP mail() function via a custom form post, etc. I won’t go into details, as a quick search on Google came up with over 225,000 pages describing this technique – here are a few.

Getting around these hacks requires detailed validation of your data.Thankfully I’ve done everything for you using the best PHP email class around, PHPMailer. My class is called SendMail and it’s an extension of the PHPMailer class. The result is a powerful script capable of sending email via SMTP or POP3, all without handing over your server to a toothless spammer.

Read more »

Custom CakePHP Errors – A Complete Run Down

Taking advantage of custom error documents usually requires tapping on an .htaccess file, as discussed in my previous custom error article. However CakePHP makes for easy custom error handling thanks to a pre-defined Cake system.

I’ll walk you through creating custom error pages, both simple and complex.

Read more »

Secure CakePHP via Sessions & Magic (Login / Logout)

Making sure a CakePHP application is secure is a total snap thanks to “sessions” – the rock animal of websites. Put on your All-Stars and boot up your MacBook – I’m about to go Discovery Channel on your ass.

Read more »

Multiple Image Uploads Into Single MySQL Table (CakePHP)

The impossible has been done – uploading multiple images in CakePHP. Find out how easy it is, and why it was never really impossible to begin with.

Read more »

3 Hidden CakePHP Functions You Can’t Live Without, Flay

CakePHP’s fattie /cake/lib folder holds many hidden treasures, that although documented in Cake’s API, lacks examples of use and simple noobie terms like “howto”. I’m here to help, so settle down.

Read more »

Easy Dynamic Database Connection in CakePHP

If you’re like me, you’re strikingly handsome you create Cake applications on your computer, then upload them for testing (and usage) to a server. It’s annoying to have to change the /app/config/database.php file for each new testing environment, especially if the same Cake application is being used on multiple machines.

Thankfully there’s a really simple way around this crap.

Read more »