Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
PHP - Sanitised application principles for security and useability

When you write a simple web based application, such as a tax calculator, it's always a good ides to echo back the values that your user filled in to the initial form as a part of the response page. That way, anyone who prints out the resulting screen will know just WHAT the question was that the page answers!

It's also a good idea (a VERY good idea - read mandatory) to sanitise the user's inputs, checking against injection attacks using dingle quotes, < characters, & characters, and so on. These checks help avoid injection attacks with Javascript and HTML, and prepare you against injection attacks against a database you may add later

When you echo back the results page and present a further copy of the form that can be filled in, you should echo the values that the user entered the previous time ... and you need to be careful to sanitise the string and make sure it will accept space characters by quoting back the value when you echo it. Users often need to correct or modify values and resubmit forms, and it's very antisocial of the programmer to present them with a completely blank form as a punishment for making just one mistake!

Finally, keep the bulk of your PHP towards the top of your code and the HTML towards the bottom. That way, you can easily change the look and feel of the page without having to rework the logic, or can easily change the logic without major work on the look and feel

These are techniques that we'll teach you from day one of our PHP Programming Course and we continue with on our PHP Techniques Workshop.

I have just written and presented, in front of my delegates, an example to show these principles all in a single piece of code.

You can see the source here and run it here.
(written 2008-06-16 18:24:09)

 
Associated topics are indexed under
G906 - Well House Consultants - Programming Standards
H117 - Security in PHP

Back to
Software - changes and delays. But courses must run on time!
Previous and next
or
Horse's mouth home
Forward to
Astroturfing - the online definition
Some other Articles
Plenty of car parking at Well House Manor, Hotel, Melksham
Accounts in PHP - an OO demo
Adding a button to a web page to print the page
Astroturfing - the online definition
PHP - Sanitised application principles for security and useability
Software - changes and delays. But courses must run on time!
CSS training - Cascading Style Sheets (UK course)
A warm welcome for visitors from the USA
Comparing Objects in C++
What a lot of files! (C++ / Polymorphism demo)
1817 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 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).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho