« It's over | Main | I can't hold out against JSP any longer »

Long since expired

Everybody has something they check—the way someone holds a spoon, the rings on their fingers. I check online order forms. Specifically, I check the form where the customer is expected to fill in the expiration date of their credit card.

There, did you notice it too? The one which would let you fill in a date in 2003? Oops, someone hard-coded the years into the order form. This is not a forward-thinking webmonkey.

After once re-hard-coding an order form at my old job for a newer set of years, I changed our code such that it automatically provides the current year plus the next ten as options. It’s not hard:

<select name="year">
<?php
$this_year = date("Y");
for ($i=0; $i<10; $i++) {
echo "<option>";
echo $this_year + $i;
echo "</option>\r";
}
?>
</select>

Go forth and write similar code in whatever other template system the Man is forcing you to use…

Now Playing: Forever from Us And Us Only by The Charlatans

Comments

This is so funny. I just did the same thing the other day, triple-checking various and sundry stupid things we’ve done for clients over the years. I think we always do this in December, don’t we (the collective “we”)? Sure, I eliminated all my non-forward thinking years ago, but that doesn’t mean I still don’t check. Sometimes I come across some silly form we made like six years ago and haven’t touched since (seriously) and I think “what the hell were you thinking??” but then again, that’s when PHP 3 was cool. Gah, I feel old.

Post a comment