Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
PHP module H112
Further Web Page and Network Handling
Exercises, examples and other material relating to training module H112. This topic is presented on public courses Learning to program in PHP, PHP Programming, PHP Programming, Learning to program in PHP

Applications often require a series of forms to be completed, with the final outcome being determined by the inputs from all the forms along the way. Furthermore, your web site may have several visitors filling in a series of forms at the same time. It's vital that you should be able to remember information from form to form, and also be able to tell your users apart from one another. This module covers the techniques used to "maintain state", and the PHP functions provided to help you do so.

Related technical and longer articles
A Web interface for your Linux admin tasks
Suggesting alternative search terms to web site users
Using current exchange rates on a web page
Using Frames with PHP
Shopping cart application in PHP

Articles and tips on this subjectupdated
4483Moving from mysql to mysqli - simple worked example
We have a big codebase of PHP code that uses MySQL databases, much of it written using mysql_ functions which were not object orineted in nature, and have been paralleled by the more recent mysqli_ functions and methods for quite some time now. The older mysql library is now deprecated, with warnings ...
4070Passing variable between PHP pages - hidden fields, cookies and sessions
Variables within a program are lost when the program exits ... unless the program takes some sort of action to save them. And if it does, you've then got to have another program pick them up to use them somehow. Web applications in PHP are a series of short-running programs. A program is run each time ...
789Hot answers in PHP
We've got a lot - a LOT of demonstrations and source code on our site. Here are a few of the most popular ones all brought together in a single listing. Enjoy ... Searching - how similar are two words? - try about source Does a particular URL exist? - try source Uploading an image to a database ...
3918Multiple page web applications - maintaining state - PHP
As you want to do more in an online application, you need to link a series of forms together. There's a limit to how much you can expect your users to enter on one page, and almost inevitably they'll want feedback as they go through a series of steps. So multiple forms is natural, with each encouraging ...
3568Telling which ServerAlias your visitor used - useful during merging domains
Someone tells you a website to visit - "go to wellhousemanor.co.uk" they say. And you'll naturally add "www." in front of it, calling up www.wellhousemanor.co.uk rather than wellhousemanor.co.uk ... or perhaps you won't. Web servers are normally set up by default to respond to a single specific host ...
3540Easy session example in PHP - keeping each customers data apart
When you go to a shop, you're not kept waiting outside until the previous customer leaves. The shop will have multiple shopping baskets / trollies, or muliple assistants. And that's the way you want it when you visit a web site too. This means that the web site programmer has to be very careful to ...
34323 digit HTTP status codes - what are they, which are most common, which should be a concern?
We often talk during web related course / course modules about the status codes that are returned by servers - but I don't think I've ever written up a (near?) complete list. They are all three digit codes, and they're grouped by hundreds - so 200 series code are success, 400 codes are requests that ...
3036Sending out an email containing HTML from within a PHP page
The mail function in PHP allows you to send a plain text email in a single function call from within your script but please read the cautions at the end of this post before you do so!. How do you send out something in HTML format, though? The mail function takes an additional (fourth) parameter of extra ...
2918Downloading a report from the web for further local analysis
There are many applications where users want to use a piece of web based software to explore data sets - to research information and come up with tables of results and lists of data which they then want to examine in more detail - explore further. How do they do that further exploration - perhaps through ...
2729Uploading a document or image to its own URL via a browser
One of the major requirements of a committee / working group such as the TransWilts Community Rail Partnership is to be able to share information - and a forum (such as Simple Machines) does that admirably. So after yesterday's meeting, I put up a forum for our initial work. But one of the side issues ...
2679How to build a test harness into your PHP
I was writing a PHP demonstration yesterday, and I wanted to include a test harness with my class definitions that I could leave in place on the live code on my server, to be silently skipped over ... but which I could re-use at a later date for testing class changes, etc. How did I do it? An environment ...
2632Shipping a test harness with your class in PHP
If you're writing a class (or group of classes) into a file you include into your main application(s) in PHP, you'll be recommended to keep the included files out of the document path so that they can't be run on their own (or, more dangerous, browsed as text if you have a different extension applied ...
936Global, Superglobal, Session variables - scope and persistance in PHP
"Global" is a poor choice of word! It really means "share this variable in this function with the variable of the same name at the top level" but there isn't a simple, easy better word for that than "Global". If you bring in code within an include / require file, then any top level code's variables ...
356Sudoku helper or sudoku cheat
Have you seen the sudoku puzzles that are being published in the Daily Telegraph and (I think) the Los Angeles times? There's a whole group of addicts out there and helper and forum web sites too. Lisa pointed the puzzle out to me recently (no, she's not an addict!) with the thought of providing a ...
425Caching an XML feed
If you're using PHP to add a newsfeed to your site, please be kind to the news feed supplier and cache the feed if your page is a popular one. I posted a couple of weeks ago ... a link to a piece of code that grabs a news feed .... and I've enhanced it now to do the caching. Here's the modified code: $feed ...
410Reading a news or blog feed (RSS) in your PHP page
If you want to quote the latest articles from an RSS (XML based) news feed on your site, is it difficult? No - it can easily be programmed in PHP. I was exploring this yesterday and have the source code showing just how easy it is in our training resources. Want to try it out? This link runs the ...
1485Copyright and theft of images, bandwidth and members.
Some poor home school kid in the USA just got the sharp end of my tongue .. I had just signed up to a political forum and so had he (he said) and he wrote: Also I was wondering if you would join my political forum at http://www.xxx.org .(I know this is an advert but it's really hard to get a new board ...
345Spotting a denial of service attack
Our web site traffic rose from 37000 hits last Wednesday to 64000 hits on Thursday. Good sales and marketing activity on our part? No - it's a potential problem; all the extra traffic came from a single location and my immediate concerns included: * Possible denial of service, where all the bandwidth ...
1549http, https and ajp - comparison and choice
In a web scenario, client to server traffic is usually carried using an http (HyperText Transfer Protocol) transport. That's both from browser to public facing server, but also in ongoing transfers from the public facing server to other servers which provide content or run business logic in many applications. But ...
1518Downloading data for use in Excel (from PHP / MySQL)
Requirement: To allow a visitor to your web site to click on a link that downloads data from the server into a Microsoft Excel spreadhseet. Solutions - I'm going to offer you two: a) To send the output as a text file - delimited by tabs between columns, and with new lines for each new line. Add appropriate ...
1515Keeping staff up to date on hotel room status
Communication - communication of the immediate status of hotel rooms, of events that have happened out of the norm, of the reasons behind each of our terms and conditions, and much more is all a vital part of running our hotel - and it's not made easier by the fact that we are (and must be) run be a ...
1505Script to present commonly used images - PHP
"What are the most popular pages in your picture library, and where are they used from?" An interesting question and I could analyze raw web logs to find out the answers. However, most of our images are managed by a script that retains extra information such as an image title, and uses are logged ... ...
1495Single login and single threaded models - Java and PHP
On Apache Tomcat courses, I find myself explaining "single login" models and on some Java courses I explain single threaded models. In both cases, there are times that newcomers to the technologies ask "does it matter". Answer - for a small and quiet application suite, probably not - but as the ...
1496PHP / Web 2 logging
It' gone quiet here for 48 hours, hasn't it? The final run up to the first week of courses for the new year and we've been catching up with everything from cleaning blinds to updating web cam systems and ironing out final issues and catching up on other paperwork. Lots of good background and not ...
1379Simple page password protection - PHP
So many demonstrations are too clever - the wood gets lost for the trees and the newcomer is left not knowing what the important bits are. So a request overnight for a REAL simple way of password protecting some content based on a single password that can be changed [in the code] from time to time provided ...
1355.php or .html extension? Morally Static Pages
You'll find many pages on our web site with .php extensions, and many more with .html extensions. "So the .php files contain executable content and the .html files do not" you may think. No - not exactly; in practise almost every page actually contains some PHP / Script elements. So WHAT, WHY, HOW? WHAT ...
1210PHP header() function - uses and new restrictions
PHP's header function allows you to change the headers on your returned content so that (examples) • The browser receives not HTML but plain text, a .jpg image or a file to save locally    example: header ('Content-type: Application/Octet-stream'); • You can change a "404" missing ...
1187Updating a page strictly every minute (PHP, Perl)
For the Clock exercise that I mentioned in my last entry, I need to update the page once a minute. Exactly once a minute. At the start of the minute. I'm using client pull, where the browser asks for the next page - so my basic request is: <meta http-equiv="refresh" content="60; url=/clock/now.php"> but ...
1183Improving searches - from OR to AND?
There's a search box on the top of all our regular pages - put a word in there, submit the form, and you'll be offered a selection of appropriate pages ... and if there's nothing relevant, you'll be offered nearby spellings. Try a search for Ireland and a search for Irelond. Search for multiple words, ...
1114PHP Image upload script
"How do I upload an image to my server?" That's a common question and I have provided many answers before ... but today I wrote a very simple script that shows just the pertinent points of uploading an image. <?php if ($_REQUEST[completed] == 1) { $newname = uniqid("whc").".jpg"; ...
1009Passing GET parameters through Apache mod_rewrite
If you're using Apache mod_rewrite to redirect a series of URLs to a single script, did you know that you can pass values entered onto a form via the GET method through as well? Simply add on %{QUERY_STRING} onto the end of your new URL. You'll need to add a ? into the target URL to ensure that the ...
904Of course I'll tell you by email
It's about the time that I should be writing the next issue of "Of Course" - our twice yearly newsletter about Open Source training, and the news from Melksham and our training centre. But there's so much happening - with Well House Manor opening earlier this month, and with an initial 3 months 'running ...
847Image maps for navigation - a straightforward example
Image maps can be a really simple and effective way of selecting from a series of options - a little bit more flexible that straightforward HTML links. We use an image map on every one of of main "Well House Consultants" pages - click on any on the languages named in our banner, and you'll be taken ...
767Finding the language preference of a web site visitor
I can (and do) identify the country of origin of over 98% of the visitors to our web site using the maxmind database. But does that tell me what their native language is? No - it only gives me a clue. A further clue is available from the accept-language header that's returned by browsers, and is available ...
542Morning image, afternoon image
"I want to show one picture on my website in the morning and a different one in the afternoon". Doesn't that sound like it's a simple request ... yet - as ever with computing - it raises a whole lot more questions, with a raft of possible answers. * Do you want the time from the server? Where's ...
565Using PHP to output images, XML, Style sheets, etc
PHP is usually used to generate a stream of HTML to be sent to the browser, but if you use the header function within your page you can use it to send any other type you wish. For example, if I include header("Content-type: image/jpeg"); then I can script the production of images. Easy? Yes, but ...
220When to use Frames
Frames are an HTML feature that people seem to love or hate. They do provide an extra power to how information can be navigated on a web page by allowing partial page refreshes and partial page scrolls BUT there are a number of things on the "downside" too. Gary White will tell you all about the downside ...
Examples from our training material
about_you.php   Information about the visitor avaialble to a web site provider
automailer   PHP script to email from the command line
cook.php   Setting and reading a cookie
cookie_demo.php   Setting and deleting a cookie
d404.html   Script run when our web site can't find a requested page
dopost.php   Using the POST method to read from a URL within a PHP script
exchange.php   Exchange rate convertor
favcol.php   cookie demo - lock in favourite colour
fromwhere.php   Tracking how visitors reach a page
gherkin.php   Download and store results from a web enquiry
imap.php   Image map controlled by PHP script
pcook.php   Setting and checking a persistent cookie
phpemenc   Emailing with enclosures from a web page
ppmh   Sending an email as HTML not plain text
pubsales.php   Cookie check for new visitor
roomstates.php   Room State Reporter
sesscart.php   Session demo - shopping cart
sessdemo.php   Session demo - shopping cart - from PHP 4.2
sessions.php5   Session demo for more recent PHP4 and PHP5 systems
sucksee.php   does a URL exist?
supermail.php   simple form for mailing
upload_test.php   How to upload a file via a web page
uploader.php   Upload a file from a browser
Injection attacks - avoiding nasty characters
Hidden fields, cookies, sessions and state - PHP
Superglobals in PHP
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Maintaining state.
Cookie examples.
Headers, Heads and Bodies.
Uses of Cookies.
Accessibility - a practical example of cookies.
Example using PHP built-in session functions.
Why email from the server?.
Informing the system owner.
Emailing system users.
Other users.
Emailing from the server.
Sending a simple email.
Adding to the headers.
Sending attachments.
A practical example of mailing from PHP.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/H112.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb