Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Changing Images

The simplest ideas are often the best ... and the simple idea of having a picture that automatically changes from time to time on your web page helps keep your customer's interest up when he returns to your site. You're seeing a picture of our dog Gypsy to the right of this block of text, but I don't know exactly which one ...

On yesterday's PHP course, I wrote an example that selects the picture that is displayed based on the number of minutes that have elapsed into the hour - you can run that page [here] and you can see the source code [here]. It's an easy step to change the "number of minutes" into a "number of hours" into the day, and produce a page that shows a different image depending on the time of day - a nighttime shot until 7 a.m., then a breakfast, followed by ... well, you'll be getting the idea.




A further request that your customers may make is for changed character sizes, backgrounds, etc - and if you provide a "service" you've a legal requirement in the UK to take all reasonable steps to ensure your service is accessible to the disabled, which means (on a web site) that you should provide this flexibility, not require your users to link via images which may not be accessible on browsers that read words for the blind, etc.

The same example code includes a simple example of using a form (or pseudo form) element to provide an input to the page, which sets a cookie and allows for a colour change to be requested and saved. In the case of the example, I have set a six hour timeout on the cookie so that it'll be reset for me for demonstration purposes by the following day ... you might choose to use a year or two.

Although both of the examples here are very short, simple, straightforward, I have enhanced them slightly since yesterday's demonstration by adding in a couple of checks to ensure that a malicious user can't inject a request for a colour that we didn't offer, or something rather more nasty. Bear in mind that even with these simples of demonstrations, you need to have one eye open for the security of your web site if you're running code on it - especially code that has user inputs!



(written 2009-12-17)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
G996 - Well House Consultants - Newsletter Scripts
  [3179] Oops - I typed ci not vi, and have lost my file ... - (2011-02-21)
  [2433] Controlling, supressing, enabling PHP error messages - (2009-10-02)
  [2360] Error Handling in Lua with assert and pcall - (2009-08-13)
  [2259] Grouping rows for a summary report - MySQL and PHP - (2009-06-27)
  [2145] Using the internet to remotely check for power failure at home (PHP) - (2009-04-29)
  [2046] Finding variations on a surname - (2009-02-17)
  [1954] mod_rewrite for newcomers - (2008-12-20)
  [1813] Ajax - going Asyncronous and what it means - (2008-09-28)
  [1743] First class functions in Lua lead to powerful OO facilities - (2008-08-07)
  [1665] Factory method example - Perl - (2008-06-04)
  [1601] Replacing the last comma with an and - (2008-04-04)
  [1505] Script to present commonly used images - PHP - (2008-01-13)
  [1487] Efficient PHP applications - framework and example - (2007-12-28)
  [1387] Error logging to file not browser in PHP - (2007-10-11)
  [1321] Resetting session based tests in PHP - (2007-08-26)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [1123] mysqldump and mysqlrestore - (2007-03-30)
  [1066] Final, Finally and Finalize - three special words in Java - (2007-02-05)
  [1001] .pdf files - upload via PHP, store in MySQL, retrieve - (2006-12-19)

H304 - PHP - DDA, Style and image handling
  [3747] An easy way to comply with the new cookie law if your site is well designed - (2012-06-02)
  [2917] Upload Image, Store in database, redisplay in browser. PHP and MySQL - (2010-08-12)
  [2715] Uploading an image, document or pdf via a browser (php) - (2010-04-10)
  [2343] World Flags in your PHP pages - (2009-08-10)
  [2031] Choosing from an image with an image map - (2009-02-08)
  [1506] Ongoing Image Copyright Issues, PHP and MySQL solutions - (2008-01-14)
  [806] Check your user is human. Have him retype a word in a graphic - (2006-07-17)


Back to
Open Source Training Centre and Courses for 2010
Previous and next
or
Horse's mouth home
Forward to
Rock and hard place .. and the relaxing right one won
Some other Articles
Day and night at Christmas
My armpit was like a zebra crossing
VAT Changes
Rock and hard place .. and the relaxing right one won
Changing Images
Open Source Training Centre and Courses for 2010
Faster network, but not faster browsing until ...
All the Cs ... and Java too
When should I use Java, Perl, PHP, or Python?
And now for some posts a bit more technical
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2539_Cha ... mages.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat