October 28, 2008

Resize Images Using PHP and GD Library

PHP provides a rich set of functions to generate and manipulate images. Most of these functions require the GD library, which is bundled with PHP since version 4.3.

The following code sample demonstrates the use of GD library to resize an image to generate its thumbnail. The script first saves the uploaded image in a specific location, it then generates a thumbnail version of the image and finally saves the generated thumbnail image in JPEG format.

October 27, 2008

Multiple Submit Buttons on HTML Forms: Alternate Methods

HTML forms often need to present a choice between two or more operations on the same data. Here is an example:

[x] User 1
[ ] User 2
[x] User 3

[ De-activate selected user(s) ] [ Permanently delete selected user(s) ]

In this article, I will outline few examples to accomplish this. All of the following examples refer to a field called "command" which specifies the operation to perform. Assume that the "verbosity" on the captions is required.