tutorial

Resizing images via the web with PHP

Oftentimes you might want to display an image on the web that is a certain size, whether to avoid breaking your beautiful (CSS of course) layout, preventing download times getting too long or so on. Intelligent people like you would of course not even consider using the HTML <img> tag's width and height properties to fake resizing, the consequence of which is usually that your reader waits for a megabyte of picture to download before seeing a messed-up 10x10 pixel thumbnail. Naughty.

Of course if you have the image in advance, and there's not too many of them, you can resize it on your computer before upload. On the other hand, if the image is getting added later and is somewhat unpredictable in nature - for instance to be uploaded by a visitor to your site - it would be nice to allow them to avoid having to do that themselves, or more likely, ruin your page because they couldn't be bothered to do so. Enter Mr PHP.

Ban "high priority" email

Oh no you didn't!Oh no you didn't!Yes, I know, your email is important. Ever so important. So important you felt the need to set it to high priority urgent must do or the world will end. Along the other 5 emails you sent about your pet cat's slight illness.

Ah, email rage. Most prevalent and annoying in the tedious office workplace. Nothing (much) annoys the Poorhouse more than the persistent, repeat misuse of the high priority option; that which Microsoft Outlook shows as a grating red exclamation mark in your inbox. That which ensures your email will be the last one the Poorhouse finds the time to read. Fortunately, there is a defence. In Outlook, it's known as "Rules".

Rename all your digital photos at once

These days digital is increasingly king, including in the sphere of photography. More and more people see the virtues of the digital camera, most obviously the ability to take 2000 pictures of your pet cat sleeping and display them repeatedly to friends and family with zero development cost to yourself.

On the subject of 2000 photos, one such frequent annoyance is that when you download them from the camera to the computer, they get rather conspicuously geeky and semantically useless filenames as DSC00001.jpg, DSC00002.jpg all the way up to DSC02000.jpg. Hitting rename 2000 times to make them a little more sensible will take up unnecessary amounts of your life up and potentially give you repetitive strain injury.

Using forms in PHP: using the form's information

Once you have created the form that the user fills in, you now need the page that does something with the information. The page itself will include PHP code in order to deal with the form information, but other than that can have any other content on it as well.

As we are assuming you know how to write basic HTML, the examples below will just illustrate how to use the entries your user put into the previous page's form in this your page. To recap, this secondary page that features the values your user input must be the page mentioned in the "action" attribute of the form they filled in, and the user must have filled in the form and clicked submit to arrive at this page. The key thing here is that you cannot simply test your page by loading it without filling in the form on the first page and pressing submit.

Using forms in PHP: setting up the form

A form is an area of a webpage that gives the user places to enter information, whether it is in the form of a box they can type text into, a dropdown list, a set of check boxes or something different. These individual parts of a form can be called controls, and in HTML terms they should all fall within the opening and closing and tag. A brief guide to writing HTML forms is available from w3schools.com.

Using forms in PHP

So Webmasters and mistresses, you've already learned how to make nice pretty forms appear on web pages you're authoring, but now you want them to actually do something? And moreover, probably you want them to do something based on the information your visitor spent hours painstakingly filling out on your site. Otherwise, they might be upset that they bothered to accomplish the form filling in the first place, no?

Typically, once a form is filled in the user presses a submit button and is taken to a new page where something related to the information they entered is done. The trick here then is to understand how information is transmitted from the first page with the form on to the second page where they are taken to, and how to use it once it's there. No-one was born knowing this.

Gmail message templates

Googlemail (aka Gmail) is just lovely, but there are a few features that converts from desktop email clients might miss. One such facility is the concept of templates.

Message templates (called Stationery in some clients) are a feature whereby if you regularly send the same basic information in an email, or lay it out in a particular format, you can save a base message that you can reuse when composing a new email instead of writing a new one from scratch.

Synchronised computing

For those people who have more copies of Windows than actual windows in their house, keeping the computers running in sync can be a slight chore. Generally, the more geeky Internet based things you use the easier it is. However even in these Web 2.0 days of Google Spreadsheets et al., most people can't get away with not storing anything actually on their own computer.

To solve this dilemma, there is such a thing as remote desktops, where a computer can act as a remote terminal insomuch as when you log in to computer 1, you're actually accessing stuff on computer 2. Guaranteed sync. However, assume you have a laptop and a desktop. You want to have the ability to not only sync the two, but when you leave the house, both computers should have the capability of working independently simultaneously, but any changes made to their files back over each other at some point in the future.

Syncing from Palm tasks to MS Access

Next up, the Poorhouse wanted to try some 2-way sync action with the Palm task (aka todo) list.

Being slightly familiar with MS Access, it was decided we'd sync the Palm tasks to an Access equivalent. Hopefully this would provide a good framework to sync them to anything else, as just the code involving the Access API would need to be replaced.

First we needed some synchronisation logic. Some methodology is required so that the sync works; tasks added in either database are added to the other, same with deletion and editing. Moreover, the correct action needs to be done - if two records don't match, which one do we go with?

DIY phone fixing saves £180

A few days ago the Poorhouse's mobile phone broke. The phone is relatively new, a nice fancyish contract phone just 4-5 months old or so. The breakage seemed strange. Whilst certainly no stranger to doing rather silly things to phones, this seemed to be a spontaneous destruction one. First it wouldn't turn on at all. Later it would, but a strange permanent leafy-pattern was etched upon the screen meaning there was no way of seeing your way around navigating the phone.

Readers: please take the time to consider how likely it was that this particular fault was covered by the extended warranty.

Syndicate content