<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joe Dolson Accessible Web Design &#187; Tutorials</title>
	<atom:link href="http://www.joedolson.com/articles/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joedolson.com/articles</link>
	<description>Tips and Commentary on Web Accessibility, Usability, and Search Marketing best practices.</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:13:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Quick Tips: URLs in WordPress development sites</title>
		<link>http://www.joedolson.com/articles/2011/05/quick-tips-urls-in-wordpress-development-sites/</link>
		<comments>http://www.joedolson.com/articles/2011/05/quick-tips-urls-in-wordpress-development-sites/#comments</comments>
		<pubDate>Fri, 13 May 2011 13:43:53 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[shortcodes]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/?p=976</guid>
		<description><![CDATA[Something I&#8217;ve occasionally found irritating when developing a web site outside of it&#8217;s long-term residence (on a temporary URL, in a subdirectory, etc.), is having to choose between either adding relative URLs, the URLs for the current address, or the URLs for the final address for internal links in the development&#160;site. Obviously, using relative URLs [...]<p><strong><a href="http://www.joedolson.com/articles/2011/05/quick-tips-urls-in-wordpress-development-sites/">Quick Tips: URLs in WordPress development sites</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<p>Something I&#8217;ve occasionally found irritating when developing a web site outside of it&#8217;s long-term residence (on a temporary <abbr title="Uniform Resource Locator">URL</abbr>, in a subdirectory, etc.), is having to choose between either adding relative URLs, the URLs for the current address, or the URLs for the final address for internal links in the development&nbsp;site. </p>
<p>Obviously, using relative URLs will work, but I&#8217;m generally reluctant to use them in any <abbr title="Content Management System">CMS</abbr> (Content Management System), knowing that I may later want to provide access to that content elsewhere on the site. One of the luxuries of a <abbr title="Content Management System">CMS</abbr> is the ability to use a single source for content which is used in multiple locations, after all&thinsp;&#8212;&thinsp;but I don&#8217;t much like paying for that with broken&nbsp;links. </p>
<p>However, and especially with a larger web site, it&#8217;s not exactly a lot of fun to have to either do a big search and replace or manually run through and replace URLs at the time of&nbsp;launch. </p>
<p>Fortunately, WordPress&#8217; shortcodes <abbr title="Application Programming Interface">API</abbr> provides an insanely easy way to get around&nbsp;this.</p>
<p>Add this to your theme&#8217;s <code>functions.php</code>&nbsp;file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'home_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you&#8217;re not comfortable editing your <code>functions.php</code> file, you can also <a href="http://www.joedolson.com/articles/downloads/url-shortcode.zip">download it as a&nbsp;plug-in</a>.</p>
<p>This very, very short line of code will provide you with the simple inline shortcode <code>[url]</code>, which will provide (obviously) the home <abbr title="Uniform Resource Locator">URL</abbr> for your WordPress web&nbsp;site.</p>
<p>You can use this in any page or post when you know the <abbr title="Uniform Resource Locator">URL</abbr> will be changing like this: <code>&lt;a&nbsp;href=&quot;[url]/pretend-page/&quot;&gt;</code>.</p>
<p>Even if you&#8217;re not planning on moving your web site, it&#8217;s clear that typing those five characters is probably a much faster way of getting your home <abbr title="Uniform Resource Locator">URL</abbr> than typing it out!
<p><strong><a href="http://www.joedolson.com/articles/2011/05/quick-tips-urls-in-wordpress-development-sites/">Quick Tips: URLs in WordPress development sites</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2011/05/quick-tips-urls-in-wordpress-development-sites/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Refining Text Presentation with your Web Browser: Windows</title>
		<link>http://www.joedolson.com/articles/2008/03/refining-text-presentation/</link>
		<comments>http://www.joedolson.com/articles/2008/03/refining-text-presentation/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 23:13:26 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[browser controls]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[text-resizing]]></category>
		<category><![CDATA[user interface design]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/2008/03/refining-text-presentation/</guid>
		<description><![CDATA[It wasn&#8217;t long ago that I wrote an article on authoring an effective text-resizing widget. In that article, I made a point not to espouse the use of text-resizing tools, since it&#8217;s generally more effective to allow people to use their browser&#8217;s built-in text-resizing&#160;functionality. In fact, browser&#8217;s allow you a great deal more control than [...]<p><strong><a href="http://www.joedolson.com/articles/2008/03/refining-text-presentation/">Refining Text Presentation with your Web Browser: Windows</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<p>It wasn&#8217;t long ago that I wrote an article on <a href="http://www.joedolson.com/articles/2008/02/developing-an-effective-text-resizing-widget/">authoring an effective text-resizing widget</a>. In that article, I made a point not to espouse the use of text-resizing tools, since it&#8217;s generally more effective to allow people to use their browser&#8217;s built-in text-resizing&nbsp;functionality. </p>
<p>In fact, browser&#8217;s allow you a great deal more control than simply <em>size</em>. Modern browsers can give you extensive control over website text, including dictating background colors, text color, base text size, minimum text size, and link attributes. This post is intended to provide a quick overview of the specific controls for most modern&nbsp;browsers.</p>
<p>Most browsers have fundamentally the same options, although the interface and location in menus is quite variable. Some are more intuitive than others, and some interfaces simply don&#8217;t quite work&nbsp;right&#8230;</p>
<ul>
<li><a href="/articles/2008/03/refining-text-presentation/#firefox23">Firefox, versions 2 and 3, Netscape&nbsp;9</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#opera9">Opera&nbsp;9</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#safari3w">Safari&nbsp;3</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#ie678">Internet Explorer&nbsp;6/7/8</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#ie78">Internet Explorer, features specific to versions&nbsp;7/8</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#ie6">Internet Explorer, features specific to version&nbsp;6</a></li>
<li><a href="/articles/2008/03/refining-text-presentation/#customcss">Custom&nbsp;Stylesheets</a></li>
</ul>
<p><span id="more-220"></span></p>
<h3 id="firefox23">Firefox, versions 2 and&nbsp;3</h3>
<p><em>Main Options: Tools &raquo; Options &raquo;&nbsp;Content</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/firefox-text-configuration-options-dialogue/' rel='attachment wp-att-221' title='Firefox text configuration options dialogue'><img src='http://www.joedolson.com/articles/wp-content/uploads/firefox-2.thumbnail.jpg' alt='Firefox text configuration options dialogue' class='floatleft' /></a>Options for text configuration in Firefox are split between three menus, as is the case in most browsers. In addition to the basic options (setting your default font and font size), you can open up menus to configure preferred browser colors, link behavior options,&nbsp;etc.</p>
<p><em>Advanced Options: Tools &raquo; Options &raquo; Content &raquo;&nbsp;Advanced</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/firefox-advanced-text-configuration-options/' rel='attachment wp-att-222' title='Firefox advanced text configuration options.'><img src='http://www.joedolson.com/articles/wp-content/uploads/firefox-2-adv.thumbnail.jpg' alt='Firefox advanced text configuration options.'  class='floatleft' /></a>In the advanced menu, Firefox gives you the options to set preferred fonts for Proportional, Serif, Sans-serif, and Monospace fonts&thinsp;&#8212;&thinsp;this can be useful, if you know what they mean, but is primarily a decorative decision. However, they also give you the ability to set your minimum font-size AND to dictate whether or not web pages will be allowed to over-ride your own browser settings for font face. The minimum font-size can be a very powerful tool for accessibility&thinsp;&#8212;&thinsp;it allows you to easily prevent any website from ever producing text at a size you are unable to&nbsp;read. </p>
<p><em>Color Options: Tools &raquo; Options &raquo; Content &raquo;&nbsp;Colors</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/firefox-text-color-options-dialogue/' rel='attachment wp-att-223' title='Firefox text color options dialogue.'><img src='http://www.joedolson.com/articles/wp-content/uploads/firefox-2-colors.thumbnail.jpg' alt='Firefox text color options dialogue.' class='floatleft' /></a>Text color options are fairly straightforward. Firefox doesn&#8217;t provide an extensive list of choices: you have only four generic objects you can choose color for. Links, visited links, text, and overall background. Importantly, however, it gives you the power to enforce your choice of text and background colors, overriding any web site text or background colors. (For the record, it does also override background images, so no worry that you&#8217;ll be left with black-on-black purely because the site is using an image for the background&nbsp;text.</p>
<p>Netscape 9 uses the same options menu as Firefox, and this will not change, since Netscape was officially killed as of March 1st, 2008. <abbr title="Rest in peace">RIP</abbr>,&nbsp;Netscape.</p>
<h3 id="opera9">Opera&nbsp;9</h3>
<p><em>Basic Options: Tools &raquo; Preferences &raquo; Web&nbsp;Pages</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/opera-9-font-configuration-settings/' rel='attachment wp-att-224' title='Opera 9 font configuration settings.'><img src='http://www.joedolson.com/articles/wp-content/uploads/opera-9.thumbnail.jpg' alt='Opera 9 font configuration settings.' class='floatleft' /></a>The options in Opera 9 are much the same as Firefox, with a significantly different organization&thinsp;&#8212;&thinsp;and a couple of glaring omissions. The first omission noted is that while Opera provides you with the option to change the default background color, it does <em>not</em> give the option to change the corresponding default <em>text color</em>. This could easily cause problems, and makes it much more difficult to choose as your preference a light-on-dark color scheme, for example. The second omission is the lack of an option to have Opera override the text colors set by the web site. The options provide are merely to configure pages without a specific style applied&thinsp;&#8212;&thinsp;leaving you with less than ideal options when it comes to preferences on a less than ideal site. In general, the basic options are extremely weak in&nbsp;Opera.</p>
<p><em>Advanced Options: Tools &raquo; Preferences &raquo; Advanced &raquo;&nbsp;Fonts</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/opera-9-advanced-font-options/' rel='attachment wp-att-225' title='Opera 9 advanced font options.'><img src='http://www.joedolson.com/articles/wp-content/uploads/opera-9-adv.thumbnail.jpg' alt='Opera 9 advanced font options.' class='floatleft' /></a>The advanced options in Opera, while providing extensive options for configuring font colors, sizes, and faces, are perhaps a bit confusing to operate. They may be a bit on the overwhelming side for some users. However, they do also give you a lot of choices. You&#8217;re presented with a list of 23 separate types of on-page text which you can modify. Rather than simply setting one base font size or face, you can individually configure settings for browser menus, toolbars, web page text, headings, and form&nbsp;input. </p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/opera-9-text-element-configuration/' rel='attachment wp-att-226' title='Opera 9 text element configuration.'><img src='http://www.joedolson.com/articles/wp-content/uploads/opera-9-font.thumbnail.jpg' alt='Opera 9 text element configuration.' class='floatleft' /></a>The one complication is that not all fields give you the same set of options. While at first glance, it&#8217;s very nice that they provide options to change browser menus, in fact they have not provide the option to change the text <em>size</em> for those elements. Ah, well. The menu to configure those text elements which are fully configurable is straight-forward and&nbsp;logical. </p>
<p>How these text presentation choices actually function, however, is perhaps a little bit mysterious. It&#8217;s not 100% accurate to say that these are choices specific to text elements. The organization doesn&#8217;t make this clear, and there&#8217;s no text to describe it, but if you change the option &#8220;Web page normal text,&#8221; this will effect <em>all</em> text on the page. This option appears to be inclusive of all the element-specific configurations expressed below. Changing this option will override whatever text-size choices the website has made. This is not apparently true of the other options: changing the specified size for <code>h1</code> did NOT override the website specifications in my&nbsp;testing.</p>
<h3>Safari 3.0 for&nbsp;Windows</h3>
<p><em>Main Options: Edit &raquo; Preferences &raquo;&nbsp;Appearance</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/safari-30-text-options/' rel='attachment wp-att-227' title='Safari 3.0 Text Options'><img src='http://www.joedolson.com/articles/wp-content/uploads/safari-3.thumbnail.jpg' alt='Safari 3.0 Text Options' class='floatleft' /></a>The basic options in version 3.0 of Safari are pretty simple, at first glance. You can pick the basic options (font face and font size) for standard and fixed-width fonts. If you want to change the default font size to one of the options provided (9-14, 16, 18, 24, 36, 48, 64, 72, 96, 144 or 288 pixels), you simply select that size and you&#8217;re set. If you want a size <em>not</em> in that list, however, you&#8217;re in for a&nbsp;surprise. </p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/safari-30-text-options-controls/' rel='attachment wp-att-229' title='Safari 3.0 Text options (controls)'><img src='http://www.joedolson.com/articles/wp-content/uploads/safari-3-text.thumbnail.jpg' alt='Safari 3.0 Text options (controls)' class='floatleft' /></a>First, Safari 3 for Windows does not provide any kind of control to save or commit your changes. They are intended to be committed immediately, with no need to save. This is counter-intuitive in the Windows operating system paradigm, particularly when making a change which is not immediately visually apparent. In the case of font changes, fortunately, as long as you have a web page open behind the control panel, you will see the results&nbsp;immediately.</p>
<p>But&#8230;if you type in the size you would like to see (in the editable text field in the upper right corner), it does not immediately take effect. This is because the change is actually implemented as soon as you <em>remove focus</em> from the text box. So, if you edit the text box manually and then close, the change will <em>not</em> be saved. If, instead, you edit the text box and then move the focus to any other field, your edit will then be&nbsp;committed.</p>
<p>The other option for freely changing text size is a vertically oriented slide control. This would be reasonably logical if it weren&#8217;t for the list of font sizes right next to it&thinsp;&#8212;&thinsp;the select control is listed from smallest to largest, but the slide control moves the opposite direction: the largest sizes at the top. Still, once you get the hang of the controls, it&#8217;s not difficult&thinsp;&#8212;&thinsp;just not really&nbsp;intuitive.</p>
<p><em>Advanced Options: Edit &raquo; Preferences &raquo;&nbsp;Advanced</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/safari-30-advanced-text-options/' rel='attachment wp-att-228' title='Safari 3.0 Advanced Text Options'><img src='http://www.joedolson.com/articles/wp-content/uploads/safari-3-adv.thumbnail.jpg' alt='Safari 3.0 Advanced Text Options' class='floatleft' /></a>The Safari advanced options provide only one additional text refining feature: the ability to set the minimum font size rendered. This is also where you can attach a custom stylesheet; but this type of feature will be discussed later. You may also note at this point that Safari offers <em>no</em> options for altering text colors, background colors or link&nbsp;colors.</p>
<h3 id="ie678">Internet Explorer&nbsp;6/7/8</h3>
<p><em>Main Options: Tools &raquo; Internet Options &raquo; General &raquo;&nbsp;Fonts</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/internet-explorer-versions-6-8-general-text-options/' rel='attachment wp-att-230' title='Internet Explorer (versions 6-8) General text options'><img src='http://www.joedolson.com/articles/wp-content/uploads/ie7.thumbnail.jpg' alt='Internet Explorer (versions 6-8) General text options' class='floatleft' /></a>The general font options in all version of Internet Explorer are quite basic&thinsp;&#8212;&thinsp;the only option available is to choose the font faces which will be provided for web page or plain text fonts. Straight forward, simple&thinsp;&#8212;&thinsp;and doesn&#8217;t do very much. For the most part, this is not likely to provide any additional accessibility, unless you happen to spend a lot of time on the web sites which have not specified a font face and have difficulty reading <em>Times New&nbsp;Roman</em>.</p>
<p><em><span class="dquo">&#8220;</span>Accessibility&#8221; Options: Tools &raquo; Internet Options &raquo; General &raquo;&nbsp;Accessibility</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/internet-explorer-versions-6-8-accessibility-options/' rel='attachment wp-att-231' title='Internet Explorer (versions 6-8) accessibility options'><img src='http://www.joedolson.com/articles/wp-content/uploads/ie7-access.thumbnail.jpg' alt='Internet Explorer (versions 6-8) accessibility options' class='floatleft' /></a>I put this section into quotes because I find the categorization of these options as being specifically &#8220;accessibility&#8221; options is a bit specious. What is actually provided under the accessibility menu are the options for allowing Internet Explorer to use your color and font settings to override web site settings. It should be noted that Internet Explorer allows you to ignore the font sizes specified on a web page, but does NOT allow you to change your own base font setting. (You can change this setting in your Windows appearance options, and it will effect web pages if the &#8220;Ignore Font Sizes&#8221; setting is&nbsp;checked.)</p>
<p>One sadly missing feature in all versions of Internet Explorer is the ability to set a minimum font-size&thinsp;&#8212;&thinsp;a feature which, in my opinion, adds great value to other&nbsp;browsers.</p>
<h3 id="ie78">Internet Explorer&nbsp;7/8</h3>
<p><em>Colors Options: Tools &raquo; Internet Options &raquo; General &raquo;&nbsp;Colors</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/internet-explorer-versions-7-8-color-options/' rel='attachment wp-att-232' title='Internet Explorer (versions 7-8) Color options'><img src='http://www.joedolson.com/articles/wp-content/uploads/ie7-color.thumbnail.jpg' alt='Internet Explorer (versions 7-8) Color options' class='floatleft' /></a>With Internet Explorer 7 and, so far, version 8 as well, the color choice menu has been redesigned from version 6. It has not been designed <em>for the better</em>, mind you. The interface is, to say the least, confusing. There are two check boxes in the new interface: &#8220;Use Hover Color&#8221;, and &#8220;Use Windows Colors&#8221;. &#8220;Use Hover Color&#8221; is fairly straightforward, although the way the interface is designed makes it unclear what color will in fact be&nbsp;used. </p>
<p><span class="dquo">&#8220;</span>Use Windows Colors,&#8221; however, is quite confusing. Unfortunately, if you have the option checked, the color selections are grayed out: giving you, in effect, no idea what &#8220;Windows Colors&#8221; will actually be. This may not be a problem in a default set up; but if you have changed your Windows Color, you may have no idea what to expect. When you uncheck the option, the color fields once again light up and give you your options to&nbsp;change.</p>
<h3 id="ie6">Internet Explorer&nbsp;6</h3>
<p><em>Colors Options: Tools &raquo; Internet Options &raquo; General &raquo;&nbsp;Colors</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/internet-explorer-6-color-options/' rel='attachment wp-att-233' title='Internet Explorer 6 Color Options'><img src='http://www.joedolson.com/articles/wp-content/uploads/ie6-color.thumbnail.png' alt='Internet Explorer 6 Color Options' class='floatleft' /></a>Although fundamentally a very similar interface to the later versions, the color selection tools in <abbr title="Internet Explorer">IE</abbr> 6 are, to me, much clearer than the later events. The grouping of features makes more sense, as does the indication of current defaults&thinsp;&#8212;&thinsp;which are at least available for link colors, if not for text and background&nbsp;colors.</p>
<p>One of the biggest problems, in my opinion, with the design of the Internet Explorer interfaces (all of them) is that rather than giving you the option to override web page settings at the same time you establish your settings, you have to create the settings and set the override selection in separate menus. In <abbr title="Internet Explorer">IE</abbr> 7 and 8, adding insult to injury, the interface takes up space to link to instructions on how to ignore presets&thinsp;&#8212;&thinsp;space which could just as easily have been occupied by a checkbox to perform that&nbsp;action. </p>
<h3 id="customcss">Custom&nbsp;Stylesheets</h3>
<p>Most browsers allow you to attach your own custom style sheet. These style sheets use the Cascading Style Sheets format to allow you very fine control over how web sites you visit will display. They are, however, somewhat beyond the skill level of the average web user. Nonetheless, it&#8217;s valuable to know that the feature is available&thinsp;&#8212;&thinsp;if you are unable to enable your browser to provide what you need, you may be able to accomplish it with custom&nbsp;styles.</p>
<p><em>Opera Custom CSS: Tools &raquo; Quick Preferences &raquo; Edit Site Preferences &raquo;&nbsp;Display</em></p>
<p><a href='http://www.joedolson.com/articles/2008/03/refining-text-presentation/opera-9-custom-stylesheet-interface/' rel='attachment wp-att-234' title='Opera 9 Custom Stylesheet Interface'><img src='http://www.joedolson.com/articles/wp-content/uploads/opera-css.thumbnail.jpg' alt='Opera 9 Custom Stylesheet Interface' class='floatleft' /></a>The richest options available at this time are for the Opera browser. Opera allows customization on a site-specific level, allowing you to specify detailed characteristics for each site you&nbsp;visit.</p>
<p><em>Firefox Custom CSS: Complicated by hand, easy with&nbsp;plugins&#8230;</em></p>
<p>In it&#8217;s default installation, Firefox simply doesn&#8217;t offer a practical way to install custom styles. However, the easy extensability of Firefox through browser add-ons solves this problem readily. The most popular and easiest to use option is the <a href="https://addons.mozilla.org/en-US/firefox/addon/2108">Stylish</a> add-on, which provides functionality to add custom styles at the site level or the global level. Additionally, Stylish maintains an <a href="http://userstyles.org/">online repository of user-created&nbsp;styles</a>. </p>
<p><em>Safari Custom CSS: Edit &raquo; Preferences &raquo;&nbsp;Advanced</em></p>
<p>You&#8217;ve already seen this menu above, and it seems fairly straightforward. I will say, however, that I had a great deal of difficulty managing style sheets. The behavior of the interface was quite buggy. It&#8217;s difficult to describe, except to say that the differentiation between selecting to <em>choose</em> a style sheet and loading a <em>new</em> style sheet was extremely weak. It was not uncommon for them to behave in a different manner from what I expected. Altogether, at this time I&#8217;d say that the functionality is <em>present</em>, but at least in my installation, nearly&nbsp;unusable.</p>
<p><em><abbr title="Internet Explorer">IE</abbr> 6/7/8 Custom CSS: Tools &raquo; Internet Options &raquo; General &raquo;&nbsp;Accessibility</em></p>
<p>Unlike Opera by default and Firefox with the Stylish plugin, Internet Explorer offers only a single global custom stylesheet to be added. Nonetheless, there&#8217;s a lot you can do with global styles: and at least the interface&nbsp;works. </p>
<h3>Conclusion</h3>
<p>Most modern browsers provide the user with the ability to set their preferred default font size, text and background colors, and link colors and decoration. Some browser provide much richer features than that, allowing site-specific options and setting a minimum base font size to prevent microscopic text. In general, browser options tend to be richer and more reliable than the same functionality provided by any web-site based text widget; but may be significantly less apparent to the&nbsp;user. </p>
<p><strong><a href="http://www.joedolson.com/articles/2008/03/refining-text-presentation/">Refining Text Presentation with your Web Browser: Windows</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2008/03/refining-text-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Usable Category Navigation in WordPress Pages</title>
		<link>http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/</link>
		<comments>http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 16:55:11 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/</guid>
		<description><![CDATA[Wordpress isn&#8217;t really designed to be used as a CMS. It&#8217;s designed for blogging&#8201;&#8211;&#8201;nonetheless, it&#8217;s a surprisingly powerful little content management system, and with a little bit of tweaking you can pretty easily turn it into a nicely flexible&#160;system. Read more about WordPress&#160;Pages. One of the challenges that needs to be dealt with is the [...]<p><strong><a href="http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/">Usable Category Navigation in WordPress Pages</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<p>
Wordpress isn&#8217;t really designed to be used as a <abbr title="Content Management System">CMS</abbr>.  It&#8217;s designed for blogging&thinsp;&#8211;&thinsp;nonetheless, it&#8217;s a surprisingly powerful little content management system, and with a little bit of tweaking you can pretty easily turn it into a nicely flexible&nbsp;system.
</p>
<div class="aside">
<p>
<a href="http://codex.wordpress.org/Pages">Read more about WordPress&nbsp;Pages.</a>
</p>
</div>
<p>
One of the challenges that needs to be dealt with is the use of Pages.  A &#8220;Page,&#8221; in WordPress parlance, is a document which sits outside the blog chronology.  For the purpose of a <abbr title="Content Management System">CMS</abbr>, you don&#8217;t really want all of your posts to be chronologically organized.  You could rewrite the Post templates and the permalink format to eliminate all date information, which would provide you with a nice <abbr title="Content Management System">CMS</abbr>-like organization&thinsp;&#8211;&thinsp;but would also eliminate the blog function.  Realistically, you probably want&nbsp;both.
</p>
<p>
It&#8217;s very easy to create a large number of WordPress pages and sort them into a hierarchy. For presentation, the default WordPress function <code>wp_list_pages</code> creates a very nice nested group of unordered lists. This can be styled using <abbr title="Cascading Style Sheets">CSS</abbr> to create either a long list of pages with inset sub pages, or a fancy <abbr title="Cascading Style Sheets">CSS</abbr>-driven set of drop down or flyout&nbsp;menus.
</p>
<p>
So far, so good. If you&#8217;ve got 10 pages, a single list is fine.  But for larger sites, you&#8217;re running into other challenges. A straight list of your 150 pages is ugly, difficult to use, and difficult to&nbsp;navigate.
</p>
<p>
But the classic drop down or flyout menu has some usability issues.  For people with mobility impairments, for example, the ability to use a mouse may be limited&thinsp;&#8211;&thinsp;and it takes a fair amount of core source hacking in order to attach the javascript needed to make these menus completely keyboard navigable. It&#8217;s easy to make certain that the top level link in each category is usable from the keyboard&thinsp;&#8211;&thinsp;so your responsibility is to make certain that the top level category link will provide access to all sub&nbsp;pages.
</p>
<p>
Again, there&#8217;s an easy solution: write links to all your further pages into your document&nbsp;content.
</p>
<p>
Ick.  This solution sucks.  First of all, if you&#8217;re creating this site for a client, you can&#8217;t necessarily rely on them to retain the content you&#8217;ve carefully created.  Second, it&#8217;s very awkward to have to hand-maintain links to every page on the site.  Why are you using a <abbr title="Content Management System">CMS</abbr> if you&#8217;re going to have to do this&nbsp;anyhow?
</p>
<p>
Thankfully, although it&#8217;s not immediately obvious, WordPress does provide a way to access the children of pages programmatically. Using this code, you can simply create a secondary navigation section which provides easily keyboard-navigable links to all pages below those top level&nbsp;documents.
</p>
<h4>The&nbsp;Code</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/h3&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span> <span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;child_of=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;title_li=&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>  
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;child_of=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;echo=0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title_li=&amp;child_of=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;sort_column=menu_order&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>
What&#8217;s going on&nbsp;here?
</p>
<div class="aside">
<p>
<a href="http://codex.wordpress.org/Using_Custom_Fields">Read more about using Custom&nbsp;Fields.</a>
</p>
</div>
<p>
First up has really nothing to do with the navigation menu itself.  This is a header for the category navigation menu, arbitrarily placed in a level 3 heading element. It&#8217;s a little oddly phrased&thinsp;&#8211;&thinsp;this is because WordPress doesn&#8217;t provide access to Category labels for Pages the same way they do for Posts. Therefore, this is actually sourcing a Custom Field&thinsp;&#8211;&thinsp;a feature available in WordPress which gives you the ability to attahc any custom information to a document.  In this case, I&#8217;ve created a custom field named &#8220;category&#8221; which contains the phrase I wish to be considered the category for this item. Generally, it&#8217;s the link text of the top level link, although you could set it to be anything you&nbsp;wish.
</p>
<p>
We&#8217;re trying to talk about usability, however, so I&#8217;m inclined to suggest sticking to something&nbsp;appropriate.
</p>
<div class="aside">
<p>
Note that the code refers to the variables <code>$post</code> and <code>$post_parent</code>. It&#8217;s important to know that &#8220;Page&#8221; is a formality which indicates a post which resides outside the chronology&thinsp;&#8211;&thinsp;from a database management perspective, <em>everything</em> is a&nbsp;post.
</p>
</div>
<p>
The second block of code is a tricky bit.  This <code>if</code> query is checking to see whether the current page is a subpage of any other page.  In general, WordPress has great built-in conditional functions&thinsp;&#8211;&thinsp;you can very easily check whether something is a page (<code>is_page()</code> or whether it&#8217;s a category page (<code>is_category()</code>. There isn&#8217;t, however, an <code>is_subpage()</code> condition.  So, this is the workaround&thinsp;&#8211;&thinsp;checking whether the current page is <em>not it&#8217;s own parent</em>. In WordPress, pages at the top level of the hierarchy are their own parents. (Let&#8217;s not get into genetics, here&#8230;I&#8217;m&nbsp;concerned.)
</p>
<p>
Next we&#8217;ll use the normal <a href="http://codex.wordpress.org/Template_Tags/wp_list_pages"><code>wp_list_pages()</code> function</a>. Again, we&#8217;re using the information about the post&#8217;s parent in order to determine what pages to list, using the <code>child_of</code> argument to retrieve only the Pages which are children of the current&nbsp;page.
</p>
<h4>Whoa, there!  I see a&nbsp;problem!</h4>
<p>
Yep, you sure do.  At this point, we&#8217;re only retrieving child navigation if we&#8217;re <em>not</em> on the top level page itself. Well, that&#8217;s great. You can get between child pages if you can find your way&nbsp;there!
</p>
<p>
So that second block of code comes into play. Same idea, except this time we&#8217;re fetching children of the current page, without checking whether the page is top level.  If it&#8217;s got children, great&thinsp;&#8211;&thinsp;we&#8217;ll display &#8216;em.  If it doesn&#8217;t&thinsp;&#8211;&thinsp;also great&thinsp;&#8211;&thinsp;we&nbsp;won&#8217;t.
</p>
<p>
This sytem does also work for multiple hierarchy levels, although it&#8217;s a bit awkward.  Here&#8217;s what you&#8217;ll get with three levels in the&nbsp;hierarchy:
</p>
<ul>
<li>Top level page, no children: displays category heading, no children. (The category heading could be removed using another conditional statement; I just haven&#8217;t done&nbsp;it.)</li>
<li>Top level page, with children: displays all descendants (children and grandchildren.) Grandchildren will be in a nested unordered list inside the list item for their&nbsp;parent.</li>
<li>Second level page, no children: displays all sibling pages (pages with the same&nbsp;parent).</li>
<li>Second level page, with children: displays all sibling pages AND displays the children of the current page, in a nested unordered list inside the list item for that&nbsp;page.</li>
<li>Third level page, no children: display all sibling pages at the grandchild&nbsp;level.</li>
</ul>
<p>And so on. This code functions in WordPress versions 2.01 and&nbsp;above.</p>
<p><strong><a href="http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/">Usable Category Navigation in WordPress Pages</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2007/02/usable-category-navigation-in-wordpress-pages/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Processing Forms with PHP, a Beginner&#8217;s Guide</title>
		<link>http://www.joedolson.com/articles/2007/02/processing-forms-with-php/</link>
		<comments>http://www.joedolson.com/articles/2007/02/processing-forms-with-php/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 01:21:15 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/2007/02/processing-forms-with-php/</guid>
		<description><![CDATA[Download PHP&#160;Script The script includes a single file with the functioning script and form, a sample blank comma separated values file you can upload to your server, and the SQL statement to create the table for this script. Otherwise, you&#8217;re on your&#160;own. The beginning stages of a web-based form are very simple: you read the [...]<p><strong><a href="http://www.joedolson.com/articles/2007/02/processing-forms-with-php/">Processing Forms with PHP, a Beginner&#8217;s Guide</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<div class="aside">
<p><a href="http://www.joedolson.com/scripts/form_processing.php">Download <abbr title="Hypertext PreProcessing">PHP</abbr>&nbsp;Script</a></p>
<p>The script includes a single file with the functioning script and form, a sample blank comma separated values file you can upload to your server, and the <abbr title="Structured Query Language (a database standard)">SQL</abbr> statement to create the table for this script.  Otherwise, you&#8217;re on your&nbsp;own.</p>
</div>
<p>The beginning stages of a web-based form are very simple: you read the <abbr title="HyperText Markup Language">HTML</abbr> guide, learn about select menus, options, form labels, radio inputs and all the myriad ways you can inveigle information from your visitors.  You also learn about the <code>action</code> and <code>method</code> attributes.  Great. So all of this <abbr title="HyperText Markup Language">HTML</abbr> you&#8217;ve learned is wonderful&thinsp;&#8211;&thinsp;but won&#8217;t actually <em>do</em> anything. You need to provide some kind of back-end rules to actually make any use of this&nbsp;information. </p>
<h4>Deciding how to use the&nbsp;Data</h4>
<p>First things first, you have to decide what you want to do with the data.  I&#8217;m only going to deal with the most common probable tasks, here&thinsp;&#8211;&thinsp;no image editing or complex database updates, just simple data management. Are you going to <a href="http://www.joedolson.com/articles/2007/02/processing-forms-with-php/#database">write your data to a database</a>?  Do you want to use it to <a href="http://www.joedolson.com/articles/2007/02/processing-forms-with-php/#file">create a file</a> which will hold a record of the transaction?  Do you want it to <a href="http://www.joedolson.com/articles/2007/02/processing-forms-with-php/#semail">send an email</a>?<br />
<span id="more-117"></span><br />
For the sake of each example, I&#8217;m going to imagine we&#8217;re creating a survey.  The form needs to submit information which will be inserted into a MySQL database which, if you choose, can be analyzed in various ways using other scripts later.  This is just about getting the data into the database.  We&#8217;ll start, therefore, by describing the form you&#8217;ll be using to collect&nbsp;information.</p>
<p>Let&#8217;s imagine a survey collecting four pieces of&nbsp;information:</p>
<ol>
<li>A reason for contacting you
<p>The reason for contact will have four options, but only one will be allowable as a choice.  This will use radio button&nbsp;inputs.</p>
</li>
<li>A list of services the contacting person might be interested in.
<p>In this case, the person will be able to select several options, so we&#8217;ll be using&nbsp;checkboxes.</p>
</li>
<li>Survey taker&#8217;s state of residence.
<p>This will be a drop down.  Only one can be chosen, but there are far too many choices for a radio input to make any&nbsp;sense.</p>
</li>
<li>Comments from the survey taker.
<p>Could be anything&thinsp;&#8211;&thinsp;so this will have to be a text&nbsp;field.</p>
</li>
</ol>
<p>The code for your form will look something like&nbsp;this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>Why are you contacting us?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1_why&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1a&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1a&quot;</span>&gt;</span>Technical Support<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1_why&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1b&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1b&quot;</span>&gt;</span>Applying for Work<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1_why&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1c&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1c&quot;</span>&gt;</span>Wanted to Hire You<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1_why&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1d&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q1d&quot;</span>&gt;</span>Other<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>What service are you interested in? (Check all that apply.)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2_service[]&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2a&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Heating&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2a&quot;</span>&gt;</span>Heating<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2_service[]&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2b&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Cooling&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2b&quot;</span>&gt;</span>Cooling<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2_service[]&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2c&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Plumbing&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2c&quot;</span>&gt;</span>Plumbing<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2_service[]&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2d&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Wiring&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2d&quot;</span>&gt;</span>Wiring<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2_service[]&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2e&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Carpentry&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q2e&quot;</span>&gt;</span>Carpentry<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>Where are you from?<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q3&quot;</span>&gt;</span>Pick your state:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q3&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q3_state&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;none&quot;</span>&gt;</span>Choose One<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MN&quot;</span>&gt;</span>Minnesota<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MT&quot;</span>&gt;</span>Montana<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;NY&quot;</span>&gt;</span>New York<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>Comments<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">legend</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q4&quot;</span>&gt;</span>Please provide additional comments about our services.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q4&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q4_comments&quot;</span> <span style="color: #000066;">rows</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">cols</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;40&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span>&gt;</span>Submit the form<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Send your Input&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>This form will be the centerpiece of our example form processing&nbsp;script.</p>
<h4>Creating your Form and your&nbsp;Script</h4>
<p>Regardless of your chosen method of using data, you&#8217;ll need to have a script which collects the information from the form. This can be the same for each processing choice&thinsp;&#8212;&thinsp;first gather all data, then build the final element which either sends your email, inputs data to your database, or adds information to your data&nbsp;file.</p>
<div class="aside">
<p><strong>What happens if you leave the action attribute blank in a&nbsp;form?</strong></p>
<p>The form will submit to itself&thinsp;&#8211;&thinsp;that is, the page which holds the form will be used to process the form information.  In <abbr title="Hypertext PreProcessing">PHP</abbr>, this simply requires you to add your form processing code to that page.  This is a workable way of handling form data for a simple isolated form, but leaving the <code>action</code> attribute empty is not valid under the <abbr title="HyperText Markup Language">HTML</abbr> 4.01 or <abbr title="eXtensible HyperText Markup Language - HTML reformulated as XML">XHTML</abbr> 1.0 doctypes. To have a page process itself, it&#8217;s preferable to use the <abbr title="Hypertext PreProcessing">PHP</abbr> global variable <code>$_SERVER['PHP_SELF']</code>, which will supply the current file&nbsp;name. </p>
<p><ins datetime="2008-06-30T10:58:00">You don&#8217;t, however, want to use this global variable &#8220;in the raw.&#8221; To make it a bit safer, you&#8217;ll want to do something more like <code>htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES)</code>, which will strip out some potentially harmful attacks. It&#8217;s not infallible; but it&#8217;s better than using <code>PHP_SELF</code> by itself!</ins></p>
</div>
<p>There are two general types of form submission methods&thinsp;&#8211;&thinsp;<code>POST</code> and <code>GET</code>. Both are useful, but in this case I&#8217;ll only be dealing with POST data.  If you want to learn more about the differences between the GET and POST methods, you might want to read an <a href="http://www.cs.tut.fi/~jkorpela/forms/methods.html">article describing the difference</a> at length.  You&#8217;ll notice that the code above has had the <code>method</code> attribute set to <code>POST</code>.  The other important attribute for forms, <code>action</code> has been left blank for&nbsp;now.</p>
<p>In the course of this article, we&#8217;re going to build a script to process this example form&thinsp;&#8211;&thinsp;our script will be called <code>process.php</code>.  For simplicity, we&#8217;ll contain the entire script in a single page.  The form itself and all the processing commands will be contained in one&nbsp;page.</p>
<h4>The First Pass: Retrieving the&nbsp;Variables</h4>
<p>Opening the&nbsp;script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// HANDLE THE INPUT</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>We&#8217;ve established the outermost boundaries of our data processing.  This snippet initiates <abbr title="Hypertext PreProcessing">PHP</abbr>, establishes a simple <code>if</code> logical query which checks whether the form has been submitted.  The data following the double forward slash? Just a comment.  Anything on the same line as a double slash is a comment&thinsp;&#8211;&thinsp;<abbr title="Hypertext PreProcessing">PHP</abbr> ignores&nbsp;it. </p>
<p>One of the most important things to consider when retrieving data from a publicly available web form is whether you can <em>trust</em> the data.  And the most important thing to realize when you&#8217;re considering this is that <em>you can never trust public input</em>. <em>Never</em>. Part of having a form online is the acknowledgement that whether through malice, incompetence, or accident, there will always be the possibility that your form will be used to send data other than what you intended.  You should take precautions, therefore, to check every piece of information that comes your&nbsp;way.</p>
<p>Text fields are the easiest fields to retrieve, but can be tricky to examine.  For more information on <abbr title="Hypertext PreProcessing">PHP</abbr> security, I highly recommend reading <a href="http://www.addedbytes.com/php/writing-secure-php/">Dave Child&#8217;s &#8220;Writing Secure <abbr title="Hypertext PreProcessing">PHP</abbr>&#8221;</a> or ordering a book specifically on the subject, such as <a href="http://www.amazon.com/exec/obidos/ASIN/1590595084/joedolsonacce-20">Pro <abbr title="Hypertext PreProcessing">PHP</abbr> Security</a> by Chris Snyder and Michael Southwell. I&#8217;ll touch lightly on the subject; but don&#8217;t count on this script for any serious&nbsp;security.</p>
<p>So what needs to go inside that commented space?  We&#8217;ll need to collect the information which was placed in the form, check and make sure it&#8217;s the type of information we were looking for, and then we&#8217;ll assign each piece of data to a variable which we can use to format our final&nbsp;result.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$q1_why</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q1_why'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$q2_service</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q2_service'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$q3_state</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q3_state'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$q4_comments</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'q4_comments'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Pretty straightforward&thinsp;&#8211;&thinsp;we&#8217;re taking the raw information from the form submission and assigning them to variables. Every piece of data sent from a form using the POST method will be stuck into <abbr title="Hypertext PreProcessing">PHP</abbr>&#8217;s $_POST array variable, retrievable using the <code>name</code> attribute of the form input. You&#8217;ll notice one thing here which doesn&#8217;t seem to quite match&thinsp;&#8211;&thinsp;the name attribute for question 2 was actually &#8220;q2_service[].&#8221;  What do the square brackets mean?  They mean that this input, when submitted, will be placed in a variable of type <code>array</code> as well.  This is what allows you to retrieve multiple answers from this question&thinsp;&#8211;&thinsp;everything checked off is now associated with the $q3_service array&nbsp;variable.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$q3_state</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q4_comments</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$q4_comments</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q4_comments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$q4_comments</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q4_comments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q1_why</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> 
<span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q2_service</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> 
<span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q3_state</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> 
<span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q4_comments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> 
<span style="color: #000088;">$error</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$process</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$process</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Slightly more complicated.  I&#8217;ve elected to skip examining the data for questions 1 and 2, because they are defined within the form.  There&#8217;s relatively little chance that they&#8217;re being faked.  Nonetheless, in a production script you may well want to inspect them. I am going to check questions 3 and 4, however.  Question 3 could be a problem because the default option is &#8220;None.&#8221; In this script, we&#8217;re going to insist that our visitors be from one of these three states.  In a real situation, you may want to allow for some other possibility&thinsp;&#8211;&thinsp;but not today.  We&#8217;re checking to see whether our visitor has failed to pick their state.  If so, we&#8217;ll set the variable <code>$error</code> equal to the boolean value &#8220;TRUE,&#8221; which we&#8217;ll use later to trigger an error&nbsp;condition.</p>
<p>With question 4, we don&#8217;t really care what the content is&thinsp;&#8211;&thinsp;but we don&#8217;t want any extra spaces and we REALLY don&#8217;t want anybody submitting <abbr title="HyperText Markup Language">HTML</abbr> formatted text.  So we&#8217;re using the <code>trim()</code> function to strip white space and the <code>strip_tags()</code> function to remove <abbr title="HyperText Markup Language">HTML</abbr>&nbsp;code.</p>
<p>Question 2 may have multiple parts.  If the user can submit multiple choices, there&#8217;s always a possibility that these multiple parts will need to be dealt with&thinsp;&#8211;&thinsp;we can&#8217;t just send the array around directly.  We&#8217;ll need to turn this array of answers into specific&nbsp;parts.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q2_service</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$q2_services</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;[&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$val</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code loops through the array of services selected and creates a string variable with each element contained in square brackets.  This doesn&#8217;t serve any programmatic purpose except to make it easy to distinguish one element from another when viewing your final&nbsp;results.</p>
<p>Finally, we string everything together&thinsp;&#8211;&thinsp;make sure every variable has been set and that <code>$error</code> is FALSE, indicating that no error has occurred. If everything&#8217;s OK, we&#8217;ll set the value of $process to TRUE and we&#8217;ll move on to actually do something with this&nbsp;information.</p>
<h4 id="database">Writing Form Data to a MySQL&nbsp;Database</h4>
<p>The first task you&#8217;ll need to accomplish is to create your database.  This won&#8217;t necessarily be available on every hosting solution. If you&#8217;re using one of the major hosting services, such as GoDaddy, you can always refer to their <a href="http://help.godaddy.com/article_list.php?topic_id=67">extensive documentation</a> on databases.  One of your first steps should always be going to your host&#8217;s help pages&thinsp;&#8211;&thinsp;any luck, and they&#8217;ll provide documentation like this which may answer a number of your questions on setting up a database.  Regardless of your hosting service, however, if you use MySQL you will have to deal with the language which defines and interacts with the database&thinsp;&#8211;&thinsp;<abbr title="Structured Query Language (a database standard)">SQL</abbr>, or Structured Query&nbsp;Language. </p>
<p>It&#8217;s well beyond the scope of this article to try and articulate the complete nature of MySQL or Structured Query Language.  To get started learning <abbr title="Structured Query Language (a database standard)">SQL</abbr>, you may want to give a look to the articles available from the <a href="http://www.w3schools.com/sql/sql_intro.asp">W3Schools&#8217; <abbr title="Structured Query Language (a database standard)">SQL</abbr>&nbsp;Tutorial</a>.</p>
<p>However, the minimum you&#8217;ll need will be a single database table with five fields.  I&#8217;m actually going to go to six, because I like to attach a timestamp to every form submission&thinsp;&#8211;&thinsp;this information can really make your data a lot more&nbsp;useful.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> survey <span style="color: #FF00FF;">&#40;</span>
sid <span style="color: #999900; font-weight: bold;">INT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span><span style="color: #000033;">,</span> 
q1_why <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">127</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span> 
q2_service <span style="color: #999900; font-weight: bold;">TEXT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span> 
q3_state <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">2</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span> 
q4_comments <span style="color: #999900; font-weight: bold;">TEXT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span> 
time_stamp <span style="color: #999900; font-weight: bold;">TIMESTAMP</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #FF00FF;">&#41;</span> 
<span style="color: #990099; font-weight: bold;">TYPE</span> <span style="color: #CC0099;">=</span> MYISAM<span style="color: #000033;">;</span></pre></div></div>

<p>This <abbr title="Structured Query Language (a database standard)">SQL</abbr> code will create your basic MySQL table with six fields.  It&#8217;ll contain an automatically incremented unique ID, create space for your fields, and keep track of when the submission occurred.  For more explanations of databases, try <a href="http://www.mysql.com">the MySQL home page</a> or consider reading a complete guide to MySQL such as <a href="http://www.amazon.com/exec/obidos/ASIN/0072224770/joedolsonacce-20">MySQL&trade;: The Complete Reference</a>, by Vikram&nbsp;Vaswani.</p>
<p>Creating the database is somewhat outside the range of what I&#8217;m trying to cover, however.  Hopefully the references provided will help you out&thinsp;&#8211;&thinsp;but for now, we&#8217;re going to have to deal with getting information <em>into</em> the database.  This, of course, will require a completely different, though related, <abbr title="Structured Query Language (a database standard)">SQL</abbr>&nbsp;query.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yourusername'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'yourpassword'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your_database'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbc</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span> <span style="color: #009900;">&#40;</span>DB_HOST<span style="color: #339933;">,</span> DB_USER<span style="color: #339933;">,</span> DB_PASSWORD<span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Failure: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span>DB_NAME<span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not select database: '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Before you can start adding information to a database, you need to attach your script to the database.  In order for it to do that, you need to supply that script with your username, your password, and the name of your database.  Now, obviously, this is a security issue.  You should never make this information easily accessible&thinsp;&#8211;&thinsp;if possible, place this information in a separate file with a difficult to guess filename, somewhere below your website&#8217;s root directory.  You can then <code>include</code> your database&nbsp;connection:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;../mydb_connect1597.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In this case, the connection file has been included one directory below the active script. Having connected to your database, you can move on and insert your&nbsp;data.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO survey VALUES ('','<span style="color: #006699; font-weight: bold;">$q1_why</span>','<span style="color: #006699; font-weight: bold;">$q2_services</span>','<span style="color: #006699; font-weight: bold;">$q3_state</span>','<span style="color: #006699; font-weight: bold;">$q4_comments</span>','now()')&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That&#8217;s all the <abbr title="Hypertext PreProcessing">PHP</abbr> code required to insert the information from your form into a database.  Now, you probably want to check that the data was correctly inserted, as&nbsp;well.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;MySQL Insertion failure.&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//for testing only</span>
<span style="color: #666666; font-style: italic;">//echo &quot;&lt;p&gt;MySQL Insertion Successful&lt;/p&gt;&quot;;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code will simply check whether the <code>mysql_query</code> was performed successfully, and notify you of the results. It also closes the database connection, since you no longer need it in this instance of the&nbsp;script.</p>
<p>That&#8217;s something like the bare minimum needed to process a form and insert the data into a MySQL database&thinsp;&#8211;&thinsp;there are scads of issues not dealt with, including many database security issues and error handling. But that&#8217;s a question for a later&nbsp;article.</p>
<h4 id="file">Placing your data in a&nbsp;file</h4>
<p>As long as you know the correct data format, you can create just about any type of file using <abbr title="Hypertext PreProcessing">PHP</abbr>.  The easiest, of course, are <code>.txt</code> and <code>.csv</code> files.  Comma separated values files tend to be a bit more useful for this kind of thing, since you can then open the file in a program such as Microsoft Excel and be able to sort the information.  Although it&#8217;s possible to create the file from the beginning with <abbr title="Hypertext PreProcessing">PHP</abbr>, it&#8217;s much easier to simply create the file in advance.  You can create a .csv format file in any text editor&thinsp;&#8211;&thinsp;simply open a blank document and save it as &#8220;survey.csv&#8221;&thinsp;&#8211;&thinsp;the quotes will be required if you&#8217;re using Microsoft&#8217;s&nbsp;Notepad.</p>
<p>Servers are protective of files.  Naturally, they don&#8217;t want to leave every file just sitting there waiting for <em>anybody</em> to edit it.  In order to prevent this, files have <em>permissions settings</em>. Each file has permissions set for three users: the owner, the group, and the WORLD&thinsp;&#8211;&thinsp;which is to say, everybody. Each user is granted specific permissions for three actions: read, write, and execute.  Most of the time, you want everybody to be able to read your documents, but only want yourself to be able to write them.  For scripts and files which will be recording data, however, you need to be a little more trusting. For more on file permissions, read &#8220;<a href="http://www.dartmouth.edu/~rc/help/faq/permissions.html"> Understanding file permissions on Unix: a brief&nbsp;tutorial</a>.&#8221;</p>
<p>Permissions are represented most commonly in 9 character strings.  Each set of three characters represents one user, and each character within that user represents one behavior.  For example, the permissions set <code>rwxrw-r-x</code> gives the owner of the file permission to read it, write it, and execute it.  The group can read and write, and the world can read and execute the&nbsp;file. </p>
<p>You need to make certain that your .csv file has permissions set which will allow your script to read it and write it.  The script probably runs with group permissions, but in some servers it may require world-wide permissions&thinsp;&#8211;&thinsp;if <abbr title="Hypertext PreProcessing">PHP</abbr> is running under a different group than the owner of the&nbsp;file.</p>
<p>The&nbsp;code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$csv_file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'survey.csv'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_writable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$csv_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_file</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// this line is for troubleshooting</span>
<span style="color: #666666; font-style: italic;">// echo &quot;&lt;p&gt;Cannot open file $csv_file&lt;/p&gt;&quot;;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You&#8217;ve defined a file pointer which can find the comma separated values file you created.  You&#8217;re checking it to see whether it&#8217;s readable and, while you&#8217;re testing, you&#8217;re providing an error message to tell you what&#8217;s going&nbsp;wrong.</p>
<div class="aside">
<p><strong>About Error&nbsp;Messages</strong></p>
<p>You don&#8217;t want to provide technical error messages in a production setting&thinsp;&#8211;&thinsp;when you&#8217;re live, you need to focus on telling your users what they need to know and nothing more.  Giving away technical information is an invitation to hackers and means nothing to the average&nbsp;user.</p>
</div>
<p>At this point, you&#8217;ve also opened the file for editing using the function <code>fopen</code>.  This function accepts two arguments: the first has to be a file pointer.  The second is a code which represents the manner in which you&#8217;re opening the file&thinsp;&#8211;&thinsp;you need to tell the script whether you want to overwrite the existing content of the file, whether you want to add information at the beginning of the file or the end, or whether you don&#8217;t intend to write to the file at&nbsp;all.  </p>
<p>The <abbr title="Hypertext PreProcessing">PHP</abbr> online manual has a complete list of this codes at <a href="http://us3.php.net/manual/en/function.fopen.php">the <code>fopen</code> function page</a>. For now, however, just know that <code>a</code> means &#8220;Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.&#8221; We&#8217;re not interested in reading the information and we don&#8217;t want to overwrite anything that&#8217;s already there, so it&#8217;s to the end of the file we&nbsp;go.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$csv_item</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$q1_why</span><span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$q2_services</span><span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$q3_state</span><span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$q4_comments</span><span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_writable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$csv_item</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//for testing</span>
<span style="color: #666666; font-style: italic;">//echo &quot;Cannot write to file&quot;;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This script creates a text string containing the four variables, checks to see whether the file is writable, and writes the string into the file.  It then closes the file by releasing the file handler you&#8217;ve created and exits the script.  The information has been saved to your file for later&nbsp;reading.</p>
<h4 id="semail">Sending your Information by&nbsp;Email</h4>
<p>In some ways, this is the easiest method.  It will simply stick the information into an email message and send it to you. What it doesn&#8217;t do is keep a running list of the uses of the form&thinsp;&#8211;&thinsp;if you wanted to use this for a survey, for example, you&#8217;d be manually entering the information from each survey submission into your chosen method of data&nbsp;tracking. </p>
<p>There are four basic elements required to send mail with <abbr title="Hypertext PreProcessing">PHP</abbr>.  The entire process is handled by a function called, predictably enough, <code>mail()</code>. This function needs four&nbsp;arguments:</p>
<ol>
<li>The destination address, or&nbsp;recipient.</li>
<li>The message&nbsp;subject.</li>
<li>The message content, or&nbsp;body.</li>
<li>Mail header&nbsp;information.</li>
</ol>
<p>Technically speaking, the mail headers are optional information.  However, I think they&#8217;re important and valuable so we&#8217;re going to go ahead and pretend that they&#8217;re&nbsp;required.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//first, define your four mail function fields</span>
<span style="color: #000088;">$recipient</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;you@yourdomain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Online Survey from Your Domain&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Online Survey:<span style="color: #000099; font-weight: bold;">\n</span>
Why are you contacting us? <span style="color: #006699; font-weight: bold;">$q1_why</span><span style="color: #000099; font-weight: bold;">\n</span>
What services are you interested in? <span style="color: #006699; font-weight: bold;">$q2_services</span><span style="color: #000099; font-weight: bold;">\n</span>
Where are you from? <span style="color: #006699; font-weight: bold;">$q3_state</span><span style="color: #000099; font-weight: bold;">\n</span>
Your Comments:<span style="color: #000099; font-weight: bold;">\n</span>
<span style="color: #006699; font-weight: bold;">$q4_comments</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: YourSurvey &lt;survey@domain.com&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;Reply-To: survey@domain.com<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is pretty straightforward&thinsp;&#8211;&thinsp;each field is a basic text string.  To make it easier to read and understand, I&#8217;m writing the questions asked into the message before the variable with the answers.  I&#8217;m also making use of <code>\n</code>&thinsp;&#8211;&thinsp;this code creates a new line in the message, and will make the results much easier to process. (It has the same effect above in the <a href="#files">CSV files&nbsp;section</a>.)</p>
<p>You can name the sending address whatever you&#8217;d like, but I&#8217;d recommend using a name which will make it easy to associate the messages sent with this particular&nbsp;script.</p>
<p>Having assigned these variables, all that&#8217;s left is to send the&nbsp;message:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recipient</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$header</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span></pre></div></div>

<p>And you&#8217;re done.  You&#8217;ve processed your&nbsp;data.</p>
<h3>Conclusion</h3>
<p>In conclusion, this is a very sparse way of addressing the complicated issue of letting people use your site interactively. It hardly touches on any of the major issues of usability or security, such as protecting your scripts from use by spammers; preventing hackers from accessing your databases; returning user-friendly error messages; or any higher level data processing.  But it&#8217;s intended to be basic&thinsp;&#8211;&thinsp;this is just an introduction.  Once you&#8217;ve gotten your feet wet, you should really look into a solid textbook which will cover some of the more difficult&nbsp;issues.</p>
<h3>Recommended&nbsp;Reading</h3>
<ul>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0596101104/joedolsonacce-20">Learning <abbr title="Hypertext PreProcessing">PHP</abbr> and MySQL</a>, by Michele E. Davis and Jon A.&nbsp;Phillips</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/0672329166/joedolsonacce-20"><abbr title="Hypertext PreProcessing">PHP</abbr> and MySQL Web Development</a>, by Luke Welling and Laura&nbsp;Thomson</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/1590598628/joedolsonacce-20">Beginning <abbr title="Hypertext PreProcessing">PHP</abbr> and MySQL 5: From Novice to Professional</a>, by W. Jason&nbsp;Gilmore</li>
<li><a href="http://www.amazon.com/exec/obidos/ASIN/1590595084/joedolsonacce-20">Pro <abbr title="Hypertext PreProcessing">PHP</abbr> Security</a>, by Chris Snyder and Michael&nbsp;Southwell</li>
</ul>
<p>I know that I&#8217;ve mentioned that Pro <abbr title="Hypertext PreProcessing">PHP</abbr> Security book already&thinsp;&#8212;&thinsp;but I can&#8217;t emphasize the importance of security enough.  By putting a form on your site and inviting any kind of input from your visitors, you&#8217;re creating a doorway into your website.  Most of the time you&#8217;ll be fine, even if you haven&#8217;t taken the precautions you should&thinsp;&#8212;&thinsp;but it&#8217;s not worth the risk if you have the opportunity to protect yourself.
<p><strong><a href="http://www.joedolson.com/articles/2007/02/processing-forms-with-php/">Processing Forms with <abbr title="Hypertext PreProcessing">PHP</abbr>, a Beginner&#8217;s Guide</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2007/02/processing-forms-with-php/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>Internet Explorer 7: Irritation of the Day</title>
		<link>http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/</link>
		<comments>http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/#comments</comments>
		<pubDate>Thu, 21 Sep 2006 16:05:24 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/</guid>
		<description><![CDATA[This post has nothing to do with IE7&#8216;s support for CSS, adherence to web standards, or general functionality. Instead, it&#8217;s a general complaint about one specific annoyance: why did Microsoft&#8217;s IE development team want IE7 to&#160;&#8220;click&#8221;? I mean, as a marketing metaphor, it&#8217;s great. Everybody wants their product to &#8220;click&#8221;. However, in this case I [...]<p><strong><a href="http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/">Internet Explorer 7: Irritation of the Day</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<p>
This post has nothing to do with <acronym title="internet explorer, version 7">IE7</acronym>&#8216;s support for <abbr title="Cascading Style Sheets">CSS</abbr>, adherence to web standards, or general functionality.  Instead, it&#8217;s a general complaint about one specific annoyance:  why did Microsoft&#8217;s <abbr title="Internet Explorer">IE</abbr> development team want IE7 to&nbsp;&#8220;click&#8221;?
</p>
<p>
I mean, as a marketing metaphor, it&#8217;s great.  Everybody wants their product to &#8220;click&#8221;.  However, in this case I think they&#8217;ve taken it a bit too&nbsp;literally.
</p>
<p><span id="more-72"></span></p>
<h3>The&nbsp;Problem</h3>
<p>
On installation, IE7 automatically turns on the Windows Explorer click sound&thinsp;&#8211;&thinsp;this effect a wide variety of actions, particularly including opening folders and <em>clicking on links</em>.  Believe it or not, these are activities I do a lot&thinsp;&#8211;&thinsp;but I like them&nbsp;silent.
</p>
<p>
One of the first things I always do with a new computer is turn off <strong>all</strong> of the default sounds.  So why does IE7 think that upgrading Internet Explorer also means I&#8217;ve changed my normal preferences about&nbsp;sounds?
</p>
<p>
I have trouble thinking of many reasons this would be done which make any serious&nbsp;sense:
</p>
<ol>
<li>It&#8217;s a bug.  Somehow, all the bug testers have their sounds turned on and nobody ever noticed this. Alternately, it actually occurs very rarely&thinsp;&#8211;&thinsp;but somehow has occurred to me on all three of my computers every single time I&#8217;ve installed it, with every beta version or release candidate I&#8217;ve looked&nbsp;at.</li>
<li>It&#8217;s a feature.  IE7 comes with a BRAND NEW Windows Explorer click sounds, and they want to make sure everybody gets to hear&nbsp;it.</li>
<li>It&#8217;s a feature.  They&#8217;re concerned that some users may not notice that they&#8217;ve clicked on links in web pages unless they receive an aural notification.  (This is, of course, true&thinsp;&#8211;&thinsp;however, those users undoubtedly are using screen readers&nbsp;anyhow.)</li>
<li>It&#8217;s not really happening.  It&#8217;s entirely in my imagination, since I&#8217;m obviously searching for excuses to be upset with&nbsp;Microsoft.</li>
</ol>
<p>
The most probable of these is that it&#8217;s actually a rare bug&thinsp;&#8211;&thinsp;but given the number of times it&#8217;s happened to me, I&#8217;m personally disinclined to consider that.  The idea that the development would intentionally program some &#8220;feature&#8221; in IE7 which actively alters a user&#8217;s settings, however, is sounding quite likely. But&nbsp;why?
</p>
<h3>The&nbsp;Solution</h3>
<p>
Assuming that you haven&#8217;t been won over by IE7&#8242;s fabulous clicking sound, you may want to turn it off.  Well, actually this is exceptionally simple&thinsp;&#8211;&thinsp;it&#8217;s just silly that you have to do it at&nbsp;all.
</p>
<p>
On Windows XP&nbsp;SP2:
</p>
<ol>
<li>Control Panel&nbsp;&rarr;</li>
<li>Sounds and Audio Devices&nbsp;&rarr;</li>
<li>Sounds&nbsp;&rarr;</li>
<li>Select &#8220;Start Navigation&#8221; in the <em>Program Events</em> selection area&nbsp;&rarr;</li>
<li>Select your sound of choice (&#8220;None&#8221;, for example) from the drop down menu below.&nbsp;&rarr;</li>
<li>Click&nbsp;&#8220;OK&#8221;</li>
</ol>
<p>
If you like the &#8220;No Sounds&#8221; option, like me, you can do this more quickly. You&#8217;ll just want to switch your Sound scheme to the default setting briefly, then switch it back to &#8220;No Sounds&#8221;.  That&#8217;ll turn everything on and off&thinsp;&#8211;&thinsp;kind of like a cold reboot for your sound&nbsp;scheme.
</p>
<p><strong><a href="http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/">Internet Explorer 7: Irritation of the Day</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2006/09/internet-explorer-7-irritation-of-the-day/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>Tips on Blogging with Blogger</title>
		<link>http://www.joedolson.com/articles/2006/01/tips-on-blogging-with-blogger/</link>
		<comments>http://www.joedolson.com/articles/2006/01/tips-on-blogging-with-blogger/#comments</comments>
		<pubDate>Thu, 19 Jan 2006 22:28:00 +0000</pubDate>
		<dc:creator>Joe Dolson</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.joedolson.com/articles/?p=7</guid>
		<description><![CDATA[In the last couple of days I&#8217;ve written a short tutorial on how to make and edit posts using the Blogger.com blogging service. I&#8217;ve found myself setting up blogs for people more and more often lately, but sometimes they need help using the service. These instructions, hopefully, will give my clients some introductory guidelines for [...]<p><strong><a href="http://www.joedolson.com/articles/2006/01/tips-on-blogging-with-blogger/">Tips on Blogging with Blogger</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web Design</small></p>
]]></description>
			<content:encoded><![CDATA[<p>
In the last couple of days I&#8217;ve written a <a href="http://www.joedolson.com/blogger/" title="Blogger Tutorial">short tutorial</a> on how to make and edit posts using the <a href="http://www.blogger.com/">Blogger.com</a> blogging service.  I&#8217;ve found myself setting up blogs for people more and more often lately, but sometimes they need help using the service. These instructions, hopefully, will give my clients some introductory guidelines for using the service!  Anybody else who has or wants a blog, of course, is free to use them as well.  I don&#8217;t go into the details of setting up the blog initially, but you can always contact me for assistance with&nbsp;that.
</p>
<p>
Setting up a blog through Blogger is one of the cheapest services I provide&thinsp;&#8211;&thinsp;if you want nothing more than a basic template as provided by Blogger, I&#8217;ll do the set up for you for a very reasonable cost. For original designs and other more extensive needs, obviously, the price&nbsp;increases.
</p>
<p><strong><a href="http://www.joedolson.com/articles/2006/01/tips-on-blogging-with-blogger/">Tips on Blogging with Blogger</a></strong><br /><small>Copyright 2004&thinsp;&ndash;&thinsp;2011 Joseph C Dolson, Accessible Web&nbsp;Design</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.joedolson.com/articles/2006/01/tips-on-blogging-with-blogger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

