Categories
Web Development

AJAX Form Validation

A pair of good articles on using AJAX for a highly responsive form validation that mixes the best attributes of server-side and client-side validation.

http://www.packtpub.com/article/ajax-form-validation-part1
http://www.packtpub.com/article/ajax-form-validation-part2

Categories
MySQL PHP

Loading configuration data from a MySQL into PHP constants

The following code will take the contents of the first row of a configuration table and create a constant for each attribute stored in it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ----------------------------- LOAD CONFIGURATION DATA FROM DATABASE -----------------------------
// Each data element in first row is placed in a constant using attribute name as constant name
// The array_slice function eliminates the first attribute in the row, 'id', which is the primary
//   key and not relevant for our purposes.
$result = mysql_query("SELECT * FROM configuration WHERE id = '1'") or die(__LINE__." SELECT Error: ".mysql_error());
if($result != false and mysql_num_rows($result)) {
    foreach(array_slice(mysql_fetch_assoc($result), 1) as $key => $val) {
        if(!defined($key)) {
            define(strtoupper($key), $val);
        } else {
            user_error("'$key' already defined.");
        }
    }
}
// ---------------------------- /load configuration data from database -----------------------------
Categories
DOS & DOS Scripting

Creating a folder named for the current date

When automating a backup script, you may want to be able to create a folder named with the current date.

This quick line will accomplish that;

1
2
@echo off
md %date:~-4,4%-%date:~-10,2%-%date:~-7,2%
Categories
Web Development

Make your site easy on the eyes with an off-white background

A glaring white background is common on websites, but a little subtlety in the background colour can make things a little easier on the eyes.

There are a number of websites that will provide color palettes, but it's best to choose a faintly off-white tone.  The idea is to cut the glare, not burden your website with a coloured background remeniscent of the web design abuses of the 90's

Pick what works for you, but a good example is #FDFDF0.  Here's a sample. The difference is subtle, but effective;

 

#FFFFFF
PURE WHITE
#FDFDF0
OFF WHITE

 

Categories
IT Resources

WordPress Resources

Plugins

  • Custom Post Limits
    • "Control the number of posts that appear on the front page, search results, and author, category, tag, and date archives, independent of each other, including specific archives.

Themes