PHP for the World Wide Web: Second Edition written by Larry Ullman
Chapter 3
Forms
Chapter 3
The form lesson was without much problem at all. In fact all went quite smoothly with this lesson! And, there were so many good pieces of information for now, and for future reference.
Creating a Simple Form
This was easy! the more diffecult challenge came in styling the form.
Krisse offered a URL at
sitepoint
which worked really well...until viewed in IE.
So, I went searching and found
Getting Fieldset Backgrounds and Legends
to Behave in IE and added it to what I
had from sitepoint and solved the problem. The problem was that
in IE the color I had chosen for the fieldset
background protruded above the form legend.
I did have to put a background and borders around the word
Form so that the border for the fieldset would not run through it in IE.
Here for future reference is a page
with 'hacks' for Internet Explorer display bugs.
How To Attack An Internet Explorer (Win) Display Bug
I found another site where form layout was done using a list.
The problem seems to be, though,
that list elements do not belong inside label elements and won't
validate. However, they (lists) do make
form styling a whole lot easier.
A List Apart
Using GET or POST
I really got a great understanding of the uses and differences between GET and POST. POST provides more security especially when it comes to data such as passwords or credit card numbers because the information is sent directly through the script to the user. With the GET message, all the data is processed through the URL and as such, is displayed.
Receiving Data from a Form in PHP
In many PHP installations, variables can
be entered easily for each input element:
$name would serve as the input variable for the
value,name and so on. But, in my situation,
it caused an incomplet form handler response.
I had to go to one of the error handling suggestions.
I had the Register_Globals
problem and went directly to the section on page 60 and solved that.
It involved naming variables in this way:
{$_POST['name']}, using the values for the various inputs.
Displaying Errors
By using this line, ini_set ('display_errors', 1); , in your script you can be made a ware of the errors in the script for that page. The 1 means that the display_errors capability is on, for that script. Easier than changing the PHP default which does not display errors, particularly if you don't have administrative control over the PHP.
SUGGESTION: display errors should be turned off for 'live' scripts, its use limited to debugging scripts as you work.
Error Reporting
Turn off all error reporting: error_reporting(0);
Report all PHP errors: error_reporting(E_ALL);
Don't show notices: error_reporting(E_ALL & ~E_NOTICE);
The Register Globals Problem
I needed to use this adjustment and discussed it here.
Manually Sending Data to a Page
This was an interesting exercise in which one needs to enter the information into the address bar which will then place that information on the page.Try it out.
The form for Chapter 3 appears below. Note:at the time of submission, I could not validate the CSS because the CSS servlet kept timing out.

