<?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>Craig Koster &#187; Software</title>
	<atom:link href="http://www.craigkoster.com/blog/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.craigkoster.com/blog</link>
	<description>Design, Develop, &#38; Deliver</description>
	<lastBuildDate>Wed, 07 Jul 2010 14:12:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Classic Dilbert</title>
		<link>http://www.craigkoster.com/blog/classic-dilbert/</link>
		<comments>http://www.craigkoster.com/blog/classic-dilbert/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 22:07:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[dilbert]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=413</guid>
		<description><![CDATA[Hilarious Dilbert today.  They&#8217;re always pretty funny but this one hits home.

]]></description>
			<content:encoded><![CDATA[<p>Hilarious Dilbert today.  They&#8217;re always pretty funny but this one hits home.</p>
<div class="thumbnail"><a href="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/50000/9000/500/59570/59570.strip.gif" rel="lightbox"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/07/59570.strip-150x150.gif" border="0" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/classic-dilbert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iMovie &#8216;08 Archiving</title>
		<link>http://www.craigkoster.com/blog/imovie-08-archiving/</link>
		<comments>http://www.craigkoster.com/blog/imovie-08-archiving/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:13:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[imovie archive mac os x]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=402</guid>
		<description><![CDATA[I&#8217;ve accumulated quite a bit of home video on my hard drive and wanted to see how I could archive all my clips onto an external USB drive.  After some Googling and experimentation I found the following to work nicely:
1) Right click in the &#8216;Events&#8217; panel at the lower left of the iMovie screen [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve accumulated quite a bit of home video on my hard drive and wanted to see how I could archive all my clips onto an external USB drive.  After some Googling and experimentation I found the following to work nicely:</p>
<p>1) Right click in the &#8216;Events&#8217; panel at the lower left of the iMovie screen and make sure &#8216;View Events By Volume&#8217; is checked.  This will list all volumes available for archiving/reading events.</p>
<p><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/07/Setting.png" alt="Setting.png" border="0" width="449" height="459" /></p>
<p>2) Just drag the events you want to archive to your backup volume (USB drive, Time Capsule, etc.) and iMovie will move them for you nicely.</p>
<p>One disadvantage of this is that anytime you want to work with or play projects that depend on the events you moved, you&#8217;ll need to make sure your backup volume is accessible.  You&#8217;ll see a little yellow caution sign on any project that uses event clips that are not available.</p>
<p><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/07/Warning.png" alt="Warning.png" border="0" width="147" height="95" /></p>
<p>I was tempted to move all my files via the Finder but I&#8217;d recommend staying away from this method as iMovie is not aware that you&#8217;re moving the files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/imovie-08-archiving/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email Standards Project</title>
		<link>http://www.craigkoster.com/blog/email-standards-project/</link>
		<comments>http://www.craigkoster.com/blog/email-standards-project/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:26:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=390</guid>
		<description><![CDATA[Email Standards Project

Our goal is to help designers understand why web standards are so important for email, while working with email client developers to ensure that emails render consistently. This is a community effort to improve the email experience for both designers and readers alike.
Just found this via http://fixoutlook.org.  Nice to see someone trying [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.email-standards.org/">Email Standards Project</a></p>
<p>
<blockquote>Our goal is to help designers understand why web standards are so important for email, while working with email client developers to ensure that emails render consistently. This is a community effort to improve the email experience for both designers and readers alike.</p></blockquote>
<p>Just found this via <a href="http://fixoutlook.org/">http://fixoutlook.org</a>.  Nice to see someone trying to bring HTML email up to standards.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/email-standards-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fever Reviewed</title>
		<link>http://www.craigkoster.com/blog/fever-reviewed/</link>
		<comments>http://www.craigkoster.com/blog/fever-reviewed/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 16:07:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[fever feedafever shaun inman review]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=364</guid>
		<description><![CDATA[I&#8217;ve been using a desktop feed reader (NewsLife) for quite a while.  While it&#8217;s worked very well I have always been hesitant to add too many new feeds as I didn&#8217;t want to feel overwhelmed with unread items.  Today, Shaun Inman released an online feed reader named Fever that promises to help you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using a desktop feed reader (NewsLife) for quite a while.  While it&#8217;s worked very well I have always been hesitant to add too many new feeds as I didn&#8217;t want to feel overwhelmed with unread items.  Today, <a href="http://www.shauninman.com/pact/">Shaun Inman</a> released an online feed reader named <a href="http://www.feedafever.com">Fever</a> that promises to help you deal with &#8220;feed clutter&#8221; by smartly analyzing which of your main feeds are &#8220;hot&#8221;.</p>
<p>After watching the introductory video I decided to take a chance and plunk down my $30 for Fever.  Setting up an account and purchasing Fever was fairly easy although there were more steps involved than most people would be used to when purchasing an app online.</p>
<p>The install for Fever went pretty well.  Although there were a few different steps to be followed the instructions were laid out nicely and easy to understand.  The install is similar to Wordpress in that there is a check to make sure your environment can support Fever and after you&#8217;ve purchased your license an automated install program sets everything up for you.</p>
<p>My first task was to import my list of feeds and that worked nicely as well.  For reference, I only have about forty feeds so we&#8217;re not talking a large number here but I didn&#8217;t see any flaws with the import process.  All imported feeds are put into the &#8216;Kindle&#8217; category which designates them as &#8220;must read&#8221; or important feeds.  I moved some of the lesser read feeds and link based feeds to the &#8216;Sparks&#8217; category.  Fever uses feeds in this category to help determine which feeds are &#8220;hot&#8221;.</p>
<p>The user interface in Fever is fantastic.  It really moves the bar up a notch for rich web applications.  Keyboard shortcuts are nicely integrated into the app which makes the switch from a desktop reader to a web reader much less painful.</p>
<p>So far the only bad thing I&#8217;ve encountered with Fever is that I really don&#8217;t have enough feeds for it to work as it&#8217;s intended.  Fever depends on having many feeds to formulate which ones are hot and only having forty feeds is kind of limiting Fever&#8217;s ability to tell me what I should be reading.  Over time I anticipate accumulating more feeds, though, as I&#8217;ll be less hesitant to subscribe to a feed to avoid clutter.</p>
<p>Most of the complaints I&#8217;ve seen so far have had to do with the fact that there is no online demo and that the application needs to be hosted on one&#8217;s own server.  These are fair complaints as plunking down your $30 without actually being able to try the app is a bit disconcerting.  There is a nice introductory video up on the Fever site that shows how Fever works, but most people (myself included) want to be able to &#8220;try before you buy&#8221;.  I&#8217;d also anticipate that there will eventually be a hosted version.  As far as I can tell, Shaun is running this whole deal by himself so initially offering only a self-hosted version may be a smart move to avoid having too big a launch that he wouldn&#8217;t be able to handle.</p>
<p>I&#8217;ve taken a few screenshots of Fever in action if you&#8217;d like to get an idea of what it looks like.</p>
<div class="thumbnail"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/hot.png" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/hot-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/kindling.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/kindling-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/sparks.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/sparks-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/single.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/single-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/read.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/read-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/preferences.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/preferences-150x150.png" border="0" /></a></div>
<div class="thumbnail" style="display:none;"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/shortcuts.png" title="Fever Screenshots" rel="lightbox[fever]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/shortcuts-150x150.png" border="0" /></a></div>
<p>I&#8217;ve only been using Fever for a couple hours now but it&#8217;s growing on me steadily.  The move from a desktop reader to a web based reader was a bit uncomfortable at first but I&#8217;m getting used to it.  From a user experience perspective, Fever really shines and as I accumulate more feeds I expect the application to become more and more useful.  The goal is to have Fever become less of a reader and more of an advisor in terms of what I should devote my time and attention to.  We&#8217;re all pressed for time and the habit of poring through your reader to examine every unread item is growing increasingly inefficient.  I&#8217;m impressed with Fever so far and I&#8217;m going to give it a shot as my main reader for the next few weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/fever-reviewed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>U.S. State Department Speaks to Twitter</title>
		<link>http://www.craigkoster.com/blog/us-state-department-speaks-to-twitter/</link>
		<comments>http://www.craigkoster.com/blog/us-state-department-speaks-to-twitter/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 21:03:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=355</guid>
		<description><![CDATA[U.S. State Department speaks to Twitter over Iran

The U.S. State Department said on Tuesday it had contacted the social networking service Twitter to urge it to delay a planned upgrade that would have cut daytime service to Iranians who are disputing their election.
I&#8217;m glad to see that Twitter postponed it&#8217;s downtime to help facilitate the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.reuters.com/article/rbssTechMediaTelecomNews/idUSWBT01137420090616">U.S. State Department speaks to Twitter over Iran</a></p>
<p>
<blockquote>The U.S. State Department said on Tuesday it had contacted the social networking service Twitter to urge it to delay a planned upgrade that would have cut daytime service to Iranians who are disputing their election.</p></blockquote>
<p>I&#8217;m glad to see that Twitter postponed it&#8217;s downtime to help facilitate the growing number of protests and related communication about the recent Iranian election.  While fascist governments have found effective ways to bend mainstream media to their will, social media is a far more difficult tiger to tame.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/us-state-department-speaks-to-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Authentication / Authorization</title>
		<link>http://www.craigkoster.com/blog/php-authentication-authorization/</link>
		<comments>http://www.craigkoster.com/blog/php-authentication-authorization/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 20:41:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=349</guid>
		<description><![CDATA[One of the big things I needed to do when switching from ASP.NET to PHP was to figure out how to do authentication and authorization.  ASP.NET is pretty strong in this area as it&#8217;s very easy to set up forms authentication and authorization rules for a site.  I found that things weren&#8217;t so [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big things I needed to do when switching from ASP.NET to PHP was to figure out how to do authentication and authorization.  ASP.NET is pretty strong in this area as it&#8217;s very easy to set up forms authentication and authorization rules for a site.  I found that things weren&#8217;t so straightforward with PHP so I took it upon myself to put together a simple example to show how to accomplish this.</p>
<div class="thumbnail"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/authentication.png" rel="lightbox"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/authentication-150x150.png" border="0" /><br />
</a></div>
<p>The example has a basic premise:  we have a log in page and a secured page.  The user cannot view the secured page until he authenticates via the log in page.  Conversely, the user cannot view the log in page if he has already been authenticated.  If he logs out then he will be taken back to the login page.</p>
<p>A working example of this can be found <a href="http://www.craigkoster.com/blog/playground/login-example.php" target="_blank">right here</a>.  You can also download the code for this example <a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/php-auth.zip">right here</a>.  You&#8217;ll need a local web server that will run PHP 5 and MySQL.</p>
<p>The example will try to authenticate a user against the database.  If the authentication is successful a session key is written and the user is redirected to the secured page.  Most of the code is self explanatory but I wanted to highlight the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//check if person is already logged in and if so redirect to index page</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;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</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: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: login-example-index.php'</span><span style="color: #009900;">&#41;</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>This code is on our log in page.  It&#8217;s basically checking to see if the person has already authenticated.  If so we want to forward them to the secured page.</p>
<p>A similar snippet is on the secured page and it checks to make sure the user has been authenticated.  If not it&#8217;ll send them back to the login page.</p>
<p>Hope this simple example will help anyone trying to put together some basic authentication.  Please note that this is a <strong>very</strong> simple example and something a little more secure and robust should be used in a production setting that has sensitive data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/php-authentication-authorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automator Workflow Techniques</title>
		<link>http://www.craigkoster.com/blog/automator-workflow-techniques/</link>
		<comments>http://www.craigkoster.com/blog/automator-workflow-techniques/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 21:24:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=333</guid>
		<description><![CDATA[Apple &#8211; Pro &#8211; Techniques &#8211; Automator Workflow Techniques

Creating a photo slideshow DVD is easy enough with iDVD. But Automator can make it even easier. The following steps will walk you through the process of creating an Automator workflow that will scan through a folder structure of files, extracting any JPEG images, and creating an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/pro/techniques/automator/index5.html">Apple &#8211; Pro &#8211; Techniques &#8211; Automator Workflow Techniques</a></p>
<p>
<blockquote>Creating a photo slideshow DVD is easy enough with iDVD. But Automator can make it even easier. The following steps will walk you through the process of creating an Automator workflow that will scan through a folder structure of files, extracting any JPEG images, and creating an iDVD slideshow containing those images.</p></blockquote>
<p>Found a nice tip on the Apple site today about creating a DVD slideshow from a batch of pictures.  Obviously this would be nice to automate and this article shows you how.  You&#8217;ll have to download the &#8216;Create Magic DVD&#8217; automator action to get this to work.  Once completed, you can just drag a folder full of images to the Automator app and it&#8217;ll create a nice DVD slideshow using iDVD.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/automator-workflow-techniques/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>15 Useful Batch Image Processors</title>
		<link>http://www.craigkoster.com/blog/15-useful-batch-image-processors/</link>
		<comments>http://www.craigkoster.com/blog/15-useful-batch-image-processors/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 17:43:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=327</guid>
		<description><![CDATA[15 Useful Batch Image Processors

Whether you’re a Web developer, Web designer or blogger, you’ve probably had to deal with the headache of converting many images to different sizes and formats. It’s not much fun if you have to convert all of them by hand. Batch image processing can reduce this process from hours of work [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.smashingmagazine.com/2008/10/02/15-useful-batch-image-processors/">15 Useful Batch Image Processors</a></p>
<p>
<blockquote>Whether you’re a Web developer, Web designer or blogger, you’ve probably had to deal with the headache of converting many images to different sizes and formats. It’s not much fun if you have to convert all of them by hand. Batch image processing can reduce this process from hours of work to just a few simple clicks.</p></blockquote>
<p>Nice article from Smashing Magazine on batch image processors.  I&#8217;m looking for one right now as I have quite a few images that I&#8217;d like to turn into web galleries.  I&#8217;m going to give a couple of the Mac ones in the list a spin and see how they do.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/15-useful-batch-image-processors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE 8</title>
		<link>http://www.craigkoster.com/blog/ie-8/</link>
		<comments>http://www.craigkoster.com/blog/ie-8/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:25:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=319</guid>
		<description><![CDATA[I just downloaded and installed IE8 on my Windows VM to see how well it conforms to web standards.  It&#8217;s definitely better than earlier versions as several noticable quirks from version 7 disappeared when I browsed some familiar sites.  This is a big plus as it shows Microsoft is moving in the right [...]]]></description>
			<content:encoded><![CDATA[<p>I just downloaded and installed IE8 on my Windows VM to see how well it conforms to web standards.  It&#8217;s definitely better than earlier versions as several noticable quirks from version 7 disappeared when I browsed some familiar sites.  This is a big plus as it shows Microsoft is moving in the right direction to minimize the number of hacks needed going forward.  Of course, now the big challenge is in getting user adoption to the new version.</p>
<p>On the downside, the browser is still very slow, taking almost twice as long to render pages as Safari or Firefox.  That&#8217;s OK, though.  Get the rendering engine right first, then worry about speed.</p>
<p><i>Update:  I just found <a href="http://ie6update.com/">this page</a> that offers a sneaky little plugin to trick users into upgrading from IE6.  Very clever and I can&#8217;t say I&#8217;m against using it despite the trickery.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/ie-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using AJAX &amp; JSON With PHP</title>
		<link>http://www.craigkoster.com/blog/using-ajax-json-with-php/</link>
		<comments>http://www.craigkoster.com/blog/using-ajax-json-with-php/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:37:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=294</guid>
		<description><![CDATA[I&#8217;ve used AJAX plenty of times before but it&#8217;s always been in an ASP.NET setting.  I&#8217;m starting to do more and more with PHP and one of the first things I tried to figure out was how to incorporate AJAX into my PHP sites.  After a quick search, it seemed that the Prototype [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used AJAX plenty of times before but it&#8217;s always been in an ASP.NET setting.  I&#8217;m starting to do more and more with PHP and one of the first things I tried to figure out was how to incorporate AJAX into my PHP sites.  After a quick search, it seemed that the <a href="http://www.prototypejs.org/">Prototype</a> Javascript framework would be a good candidate to work with.  It proved to be a great choice as it was easy to use and well documented.</p>
<p>I&#8217;ve created a simple example that shows how to make an AJAX request to a PHP page and return results using the Prototype library.  The first step is to <a href="http://www.prototypejs.org/download">download the latest version</a> of Prototype (for this example it&#8217;s 1.6.0.3).  It should be a single file that you can drop into a directory to use for this tutorial.</p>
<p>Next, create a file named get-person.php in the same directory as the Prototype file you downloaded.  Open up your favorite editor and paste the following into the file:</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;">html</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>PHP / AJAX / JSON / PROTOTYPE<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;prototype-1.6.0.3.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
		function getPerson(id, target)
		{
			//create new ajax request from prototype library
			new Ajax.Request(&quot;get-person-handler.php&quot;, 
			{
				//inline function to handle success
				onSuccess: function(transport) 
				{
					//get json object from transport
					var person = transport.responseJSON;
&nbsp;
					//use object properties to populate element
					$(target).innerHTML = person.name;
				},
				parameters: { personId: id }
			});
		}
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
 	<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;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:35px;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
 	<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;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Get Person&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;getPerson($('id').value, 'personDisplay');&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;personDisplay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>This is a simple file that has one Javascript method we&#8217;ll use to invoke Prototype&#8217;s Ajax object.  The Ajax.Request method will send a POST containing an ID to our PHP file and it will handle the request and return a response formatted in JSON.</p>
<p>Create another file in the same directory called get-person-handler.php and drop the following code into it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #666666; font-style: italic;">#this needs to be first!
</span><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#create array of person objects
</span><span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'John Doe'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Jane Smith'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Steve Johnson'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#get the id from the post
</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'personId'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//create return array and populate with id and name</span>
<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#return json string
</span><span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see, this file handles the POST request, get&#8217;s the ID from the posted data, looks up the person in the array we&#8217;ve created, and returns the data formatted in JSON.</p>
<p>You should be able to load the get-person.php file into your browser, enter an ID (either 1, 2, or 3) into the text box, and click &#8216;Get Person&#8217; to populate the screen with the person&#8217;s name.  Note that since these are PHP files, you&#8217;ll need a local web server running on your machine.</p>
<p>It&#8217;s a pretty simple setup, but I&#8217;ve found that you need to start simple when working with new languages and frameworks.  The next step might be to create a Person class in PHP and return person objects to the client via JSON.  We could also put in some database code to fetch the data from MySQL instead of using our static array.</p>
<p>You can download an archive with the three files in the example <a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/example.zip" title="Example.zip">by clicking here</a>.</p>
<p>A working example of this tutorial is <a href="http://www.craigkoster.com/blog/playground/get-person.php">right here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/using-ajax-json-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
