<?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>Likesalmon.net &#187; Musings</title>
	<atom:link href="http://likesalmon.net/category/musings/feed/" rel="self" type="application/rss+xml" />
	<link>http://likesalmon.net</link>
	<description>Web development for designers</description>
	<lastBuildDate>Sat, 21 Jan 2012 20:40:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>OGG Encoding for HTML5 Audio</title>
		<link>http://likesalmon.net/ogg-encoding-for-html5-audio/</link>
		<comments>http://likesalmon.net/ogg-encoding-for-html5-audio/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 22:47:40 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=661</guid>
		<description><![CDATA[The html5 &#60;audio&#62; tag needs an mp3 file and and ogg file to be cross-browser compatible. For best results, only encode raw, wav, or aiff files this way. Mp3 to ogg will look like it works, but the file won&#39;t play on Firefox. Encode Install oggenc: $ sudo apt-get install vorbis-tools Encode: $ oggenc -q [...]]]></description>
			<content:encoded><![CDATA[<p>The html5 <code>&lt;audio&gt;</code> tag needs an mp3 file and and ogg file to be cross-browser compatible.  For best results, only encode raw, wav, or aiff files this way.  Mp3 to ogg will look like it works, but the file won&#39;t play on Firefox.</p>
<h2>Encode</h2>
<ol>
<li>Install oggenc: $ sudo apt-get install vorbis-tools</li>
<li>Encode: $ oggenc -q 6 input.wav -o output.ogg</li>
</ol>
<h2>The HTML:</h2>
<p><code>&lt;audio controls="controls" preload="auto" autobuffer autoplay id="player"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;source src="http://alialujah.com/files/3513/2641/1365/a-house-a-home.mp3" type="audio/mpeg" /&gt;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;source src="http://alialujah.com/files/3813/2648/7285/a-house-a-home.ogg" type="audio/ogg" /&gt;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;Aw dang! Your browser does not support html5.<br />
&lt;/audio&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/ogg-encoding-for-html5-audio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://alialujah.com/files/3513/2641/1365/a-house-a-home.mp3" length="6997510" type="audio/mpeg" />
<enclosure url="http://alialujah.com/files/3813/2648/7285/a-house-a-home.ogg" length="6750762" type="audio/ogg" />
		</item>
		<item>
		<title>.htaccess for Magento pretty URLs</title>
		<link>http://likesalmon.net/htaccess-for-magento-pretty-urls/</link>
		<comments>http://likesalmon.net/htaccess-for-magento-pretty-urls/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 00:36:43 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=655</guid>
		<description><![CDATA[I was pulling my hair out over this because Magento failed to produce an .htaccess file after I enabled url rewrites on my local dev server. I searched the old internets and found nothing! I ended up using the same .htaccess arguments as I do for WordPress and it worked great. To enable url rewrites, [...]]]></description>
			<content:encoded><![CDATA[<p>I was pulling my hair out over this because Magento failed to produce an .htaccess file after I enabled url rewrites on my local dev server.  I searched the old internets and found nothing!  I ended up using the same .htaccess arguments as I do for WordPress and it worked great.</p>
<p>To enable url rewrites, go to System > Configuration > Web > Search Engines Optimization > Use Web Server Rewrites and choose yes.</p>
<p>Copy the following into a blank file and save it in the root of your Magento install as &#8220;.htaccess&#8221;:</p>
<p>&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteRule ^index\.php$ &#8211; [L]<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /index.php [L]<br />
&lt;/IfModule&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/htaccess-for-magento-pretty-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>And the eCC compatible shopping cart winner is&#8230;</title>
		<link>http://likesalmon.net/and-the-ecc-compatible-shopping-cart-winner-is/</link>
		<comments>http://likesalmon.net/and-the-ecc-compatible-shopping-cart-winner-is/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 22:55:15 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[E-Commerce]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=649</guid>
		<description><![CDATA[Opencart! No wait&#8230; it was actually LiveCart. Ed. Note 9/8/11: LiveCart made me a liar.  Turns out its broken, the community is non-existent, and the documentation is incomplete.  After struggling with PHP error after error for hours yesterday, I&#8217;ve given it up and my search for an eCC compatible shopping cart continues.  I remain impressed [...]]]></description>
			<content:encoded><![CDATA[<p>Opencart! <del>No wait&#8230; it was actually LiveCart.</del></p>
<p><em>Ed. Note 9/8/11: LiveCart made me a liar.  Turns out its broken, the community is non-existent, and the documentation is incomplete.  After struggling with PHP error after error for hours yesterday, I&#8217;ve given it up and my search for an eCC compatible shopping cart continues.  I remain impressed by Opencart though, and I&#8217;m hoping like hell that I get Quickbooks integration through <a href="http://consolibyte.com/" target="_blank">consolibyte</a>.  I found them through the Opencart forums and their web connector is in beta.  Here&#8217;s hopin&#8217;!<br />
</em></p>
<p>&nbsp;</p>
<p>But not because it&#8217;s the best.  Its just the only one that actually works with eCC and Quickbooks.  The reason?  Variations.</p>
<h2>Variations are everything</h2>
<p>Quickbooks gives all items (the QB name for products) a unique item number. Variations on a product (like size and color) also get an item number. So if I am selling widgets, I would go into Quickbooks and add a new item called Widget, and Quickbooks would assign Widget item number 1. I have all different kinds of widgets so I&#8217;d leave the inventory amount at 0. Now I have to add a style (QB&#8217;s word for variations) for each kind of widget I&#8217;m selling. I have large widgets and small widgets and they come in green or red. So I add a style for each combo, large red, small red, large green, and small green.</p>
<p>When I save and look at the list of all my items, I find that I now have an entry for Widget with no styles, and an entry for each widget combination. Large red widgets are item number 2, small red widgets are item number 3, and so on. Quickbooks treats every variation as a unique product, which makes a lot of sense when you think about how hard it would be to track inventory otherwise. Unfortunately of the three carts I tested (Opencart, Livecart, and Prestashop), Livecart is the only only that works like this. And this is essential. So Livecart it is!</p>
<h2>But Opencart was soooo good!</h2>
<p>If Quickbooks integration wasn&#8217;t an issue, the winner would be Opencart by a mile. It&#8217;s <em>really</em> nice to use. The admin area (and the frontend while we&#8217;re at it) was super fast and just beautiful. Adding products and variations was a breeze. The workflow was so smooth and well thought out. Everything just made so much <em>sense</em>! I can&#8217;t say that about Livecart or Prestashop, which are both pretty slopping in comparison.</p>
<p>Code-wise Opencart was a big stand-out as well. No smarty templating to deal with, the code is clean, and the directory structure makes sense. Themeing is straight forward. All in all an exemplary MVC application. If only I could use it!</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/and-the-ecc-compatible-shopping-cart-winner-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Livecart 500 Internal Server Error on Install</title>
		<link>http://likesalmon.net/livecart-500-internal-server-error-on-install/</link>
		<comments>http://likesalmon.net/livecart-500-internal-server-error-on-install/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 19:08:58 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[E-Commerce]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=643</guid>
		<description><![CDATA[I just installed Livecart on my local development machine and got a 500 Internal Server error when I visited the site. My permissions were set correctly. The Apache log was showing this error: livecart/.htaccess: Options not allowed here Never seen that one before! I fixed it by following tristanC&#8217;s advice on this forum post. Just [...]]]></description>
			<content:encoded><![CDATA[<p>I just installed Livecart on my local development machine and got a 500 Internal Server error when I visited the site.  My permissions were set correctly.  The Apache log was showing this error: <code>livecart/.htaccess: Options not allowed here</code></p>
<p>Never seen that one before!  I fixed it by following tristanC&#8217;s advice on <a href="http://drupal.org/node/101197" title="" target="_blank">this forum post</a>.</p>
<p>Just edit /etc/apache2/mods-available/userdir.conf and add Options as the last argument on the AllowOverride line. Then restart Apache and you&#8217;re golden!</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/livecart-500-internal-server-error-on-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>eCC compatible shopping cart reviews</title>
		<link>http://likesalmon.net/ecc-compatible-shopping-cart-reviews/</link>
		<comments>http://likesalmon.net/ecc-compatible-shopping-cart-reviews/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 02:33:59 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[E-Commerce]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=631</guid>
		<description><![CDATA[I have a client who uses eCC for quickbooks integration with their webstore. Originally we had them on the WP E-Commerce plugin, but the new version (3.8) is badly broken, and after a horrendous couple days trying to fix it I&#8217;m forced to abandon ship. So I went through the list of eCC compatible shopping [...]]]></description>
			<content:encoded><![CDATA[<p>I have a client who uses <a href="http://www.webgility.com/">eCC</a> for quickbooks integration with their webstore. Originally we had them on the WP E-Commerce plugin, but the new version (3.8) is <em>badly</em> broken, and after a horrendous couple days trying to fix it I&#8217;m forced to abandon ship. So I went through the list of eCC compatible shopping carts hoping to find a suitable replacement.</p>
<h2>The List</h2>
<p>Here&#8217;s the full list of eCC compatible shopping carts from their website:</p>
<ul>
<li>Avactis</li>
<li>osCMax</li>
<li>BigCommerce</li>
<li>Pinnacle Cart</li>
<li>ClaimTheWeb</li>
<li>Prestashop</li>
<li>CRE Loaded</li>
<li>Shop-Script</li>
<li>CS-Cart</li>
<li>Ubercart</li>
<li>CubeCart</li>
<li>ViArt Shop</li>
<li>Interspire</li>
<li>BigCommerce</li>
<li>VirtueMart</li>
<li>LiveCart</li>
<li>Volusion</li>
<li>Magento</li>
<li>WordPress</li>
<li>Mal&#8217;s eCommerce</li>
<li>X-Cart</li>
<li>OpenCart</li>
<li>Zen Cart</li>
<li>3d Cart</li>
<li>osCommerce</li>
</ul>
<h2>The Criteria</h2>
<h3>Open Source</h3>
<p>First of all, non-open source carts were taken out of the running immediately, with the briefest of overviews if they looked interesting. In addition to the cost, I&#8217;ve learned from harsh experience that closed-source shopping carts are a nightmare to work with (xSilva anyone?). If I can&#8217;t get into the guts of the thing, its not worth wasting my time.</p>
<h3>Pretty Backend</h3>
<p>Since I actually have to sell this thing to a client, its got to look good. I don&#8217;t have time to do customisations on the admin area. Its got to be attractive and usable out of the box.</p>
<h3>Good Documentation</h3>
<p>Its hard to find, as many projects have moved over to the &#8220;knowledge base&#8221; style of not-really-documentation, but its pretty important. If the docs are bad or non-existent, its got to have a good forum and an active community.</p>
<h3>MVC</h3>
<p>Once you go MVC you never go back. Shopping carts are way to complex to use old coding styles.</p>
<h2>The Losers</h2>
<h3>Closed Source and Closed Core Losers</h3>
<p>The standout among closed-source carts was Interspire. I didn&#8217;t use it but it looks super slick. Probably a good turn-key solution (as if that ever really works). I also included closed-core carts (i.e. <em>&#8220;97% open source!&#8221;</em>) in this losers list because they tend to be just as useless as closed-source.</p>
<ul>
<li>Avactis</li>
<li>BigCommerce</li>
<li>Pinnacle Cart</li>
<li>ClaimTheWeb</li>
<li>CRE Loaded</li>
<li>Shop-Script</li>
<li>CS-Cart</li>
<li>CubeCart</li>
<li>ViArt Shop</li>
<li>Interspire</li>
<li>BigCommerce (Interspire&#8217;s hosted solution)</li>
<li>Volusion</li>
<li>Mal&#8217;s eCommerce (Free, but hosted only)</li>
<li>X-Cart</li>
<li>3d Cart</li>
</ul>
<h3>Open-source Losers</h3>
<p>Carts that made this list include those that didn&#8217;t make the criteria above and carts that are based on a CMS, like Drupal and Joomla.  They may be great, but my bad experience with WP E-Commerce has soured me on those.</p>
<ul>
<li>osCMax
<ul>
<li>No updates since 2010</li>
<li>Drupal based</li>
</ul>
</li>
<li>Ubercart
<ul>
<li>Drupal based</li>
</ul>
</li>
<li>VirtueMart
<ul>
<li>Joomla based</li>
</ul>
</li>
<li>Magento
<ul>
<li>A sea of terrible reviews that site code bloat, bad load times, overly complex markup</li>
</ul>
</li>
<li>WP E-Commerce
<ul>
<li>I was really excited about this project initially.  Latest upgrade (3.8) was a huge step in the wrong direction.  I&apos;m of the opinion now that WordPress is not an appropriate platform for e-commerce.</li>
<li>Hard to customise</li>
<li>Documentation has disappeared</li>
<li>Basic functionality broken out of the box</li>
<li>Confusing backend</li>
</ul>
</li>
<li>Zen Cart
<ul>
<li>MVC based, but&#8230;</li>
<li>Messy documentation</li>
<li>Ugly, outdated backend</li>
</ul>
</li>
<li>osCommerce
<ul>
<li>Also MVC based (Zen Cart was based on osCommerce) but again&#8230;</li>
<li>Bad documentation</li>
<li>Ugly backend</li>
</ul>
</li>
</ul>
<h2>The Preliminary Winners!</h2>
<p>I&#8217;ve narrowed it down to 3:</p>
<ul>
<li>PrestaShop
<ul>
<li>MVC</li>
<li>Small &amp; Fast (according to reviews)</li>
<li>Actual documentation!</li>
<li>Active community</li>
<li>Smarty templating (boo!)</li>
</ul>
</li>
<li>LiveCart
<ul>
<li>MVC</li>
<li>Passable backend</li>
<li>Smarty templating (blech!)</li>
<li>Concrete5-style blocks</li>
<li>Backend not compatible with IE (uh-oh!)</li>
</ul>
</li>
<li>OpenCart
<ul>
<li>MVC +L
<ul>
<li>Here&apos;s a rundown of the specific flavor of OpenCart&#8217;s MVC: <a href="http://www.opencart.com/forum/viewtopic.php?f=20&#038;t=4113" title="">http://www.opencart.com/forum/viewtopic.php?f=20&#038;t=4113</a></li>
</ul>
</li>
<li>Very little documentation</li>
<li>Feature poor according to (old) reviews</li>
<li>Active community</li>
<li>PHP templating! No Smarty to learn</li>
<li><em>Really</em> slick backend, the best of the bunch</li>
<li>Lots of ajaxy javascript animations in front and back</li>
</ul>
</li>
</ul>
<p>Now I have to download and install the winners.  Check back for the grand finalist!</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/ecc-compatible-shopping-cart-reviews/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Novacut is back!</title>
		<link>http://likesalmon.net/novacut-is-back/</link>
		<comments>http://likesalmon.net/novacut-is-back/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 18:01:33 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=616</guid>
		<description><![CDATA[Support Novacut, a pro open source video editor! Its an idea whose time has definitely come:]]></description>
			<content:encoded><![CDATA[<p>Support <a href="http://www.kickstarter.com/projects/novacut/novacut-pro-video-editor">Novacut</a>, a pro open source video editor!  Its an idea whose time has definitely come:</p>
<p><iframe frameborder="0" height="410px" src="http://www.kickstarter.com/projects/novacut/novacut-pro-video-editor/widget/video.html" width="480px"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/novacut-is-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Milholland Bicycle Company</title>
		<link>http://likesalmon.net/milholland-bicycle-company/</link>
		<comments>http://likesalmon.net/milholland-bicycle-company/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 01:11:08 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=610</guid>
		<description><![CDATA[Did I ever mention that my brother builds the best bikes in the world? He built a mountain bike for me that is the best thing I&#8217;ve ever ridden. Check him out! Sweet new website: http://www.milhollandcycles.com/ Facebook: Milholland Cycles]]></description>
			<content:encoded><![CDATA[<p>Did I ever mention that my brother builds the best bikes in the world?  He built a mountain bike for me that is the best thing I&#8217;ve ever ridden.  Check him out!</p>
<p>Sweet new website: <a href="http://www.milhollandcycles.com/" title="Milholland Cycles Website">http://www.milhollandcycles.com/</a></p>
<p>Facebook: <a href="http://www.facebook.com/profile.php?id=100001261287125" title="Milholland Cycles on Facebook">Milholland Cycles</a></p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/milholland-bicycle-company/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Javascript to a Concrete5 template the right way</title>
		<link>http://likesalmon.net/add-javascript-to-a-concrete5-template-the-right-way/</link>
		<comments>http://likesalmon.net/add-javascript-to-a-concrete5-template-the-right-way/#comments</comments>
		<pubDate>Fri, 27 May 2011 20:51:11 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=600</guid>
		<description><![CDATA[jQuery is included by default in Concrete5. Here&#8217;s how to add your own script: Put your .js file in the /js directory in the root of your Concrete5 install. In your theme&#8217;s elements/header.php file, add the following just before &#60;?php Loader::element('header_required'); ?&#62;: &#60;?php $html = Loader::helper('html'); $this-&#62;addHeaderItem($html-&#62;javascript('my_script.js')); ?&#62; If you want to include your javascript [...]]]></description>
			<content:encoded><![CDATA[<p>jQuery is included by default in Concrete5.  Here&#8217;s how to add your own script:</p>
<p>Put your .js file in the <code>/js</code> directory in the root of your Concrete5 install.  In your theme&#8217;s <code>elements/header.php</code> file, add the following just before <code>&lt;?php Loader::element('header_required'); ?&gt;</code>:</p>
<p><code>&lt;?php<br />
    $html = Loader::helper('html');<br />
    $this-&gt;addHeaderItem($html-&gt;javascript('my_script.js'));<br />
?&gt;</code></p>
<p>If you want to include your javascript file only when the user is <em>not</em> in edit mode, use this instead:</p>
<p>&lt;?php<br />
    global $cp;<br />
    $html = Loader::helper(&#8216;html&#8217;);<br />
    if (!$cp-&gt;canWrite()) {<br />
        $this-&gt;addHeaderItem($html-&gt;javascript(&#8216;script.js&#8217;));<br />
    }<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/add-javascript-to-a-concrete5-template-the-right-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>We&#8217;re getting the band back together!</title>
		<link>http://likesalmon.net/were-getting-the-band-back-together/</link>
		<comments>http://likesalmon.net/were-getting-the-band-back-together/#comments</comments>
		<pubDate>Fri, 13 May 2011 18:46:56 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[theatre]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=592</guid>
		<description><![CDATA[I met my wife 5 years ago at the beginning of a run of the Sondheim musical Assassins at ART here in Portland. I played John Hinckley, Jr., the guy who shot Reagan in &#8217;81. It was an amazing show, and not just because I met the love of my life. The show itself is [...]]]></description>
			<content:encoded><![CDATA[<p>I met my wife 5 years ago at the beginning of a run of the Sondheim musical Assassins at ART here in Portland.  I played John Hinckley, Jr., the guy who shot Reagan in &#8217;81.  It was an amazing show, and not just because I met the love of my life.  The show itself is great, the cast was stellar, we won a bunch of Drammies&#8230; its one of the best things I ever did as an actor.  </p>
<p>I can hardly believe it, but  thanks to <a href="http://www.stumptownstages.com" title="">Stumptown Stages</a> and <a href="http://www.cerimonhouse.org" title="">Cerimon House</a> we get to do it again!  Next Tuesday and Wednesday I&#8217;m singing in a benefit concert along with almost the whole cast of the &#8217;06 Assassins, with the addition of legendary Portland performers Susannah Mars and Margie Boule.  If you missed it the first time, you gotta check this out!</p>
<p><a href="http://www.cerimonhouse.org/calendar-of-events/"><img src="http://likesalmon.net/wp-content/uploads/2011/05/64-780x1024.jpg" alt="" title="Songs of Sondheim" width="780" height="1024" class="alignnone size-large wp-image-593" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/were-getting-the-band-back-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clever checkbox handling with PHP</title>
		<link>http://likesalmon.net/clever-checkbox-handling-with-php/</link>
		<comments>http://likesalmon.net/clever-checkbox-handling-with-php/#comments</comments>
		<pubDate>Fri, 06 May 2011 16:19:47 +0000</pubDate>
		<dc:creator>Ammon</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://likesalmon.net/?p=585</guid>
		<description><![CDATA[An unchecked checkbox returns nothing when a form is submitted, but most of the time you want it to return something, so you can work with that $_POST variable. This is easy with the addition of a hidden input with the same name as your checkbox: &#60;?php &#160;&#160;&#160;&#160;// If the box was checked, keep it [...]]]></description>
			<content:encoded><![CDATA[<p>An unchecked checkbox returns nothing when a form is submitted, but most of the time you want it to return <em>something</em>, so you can work with that <code>$_POST</code> variable.  This is easy with the addition of a hidden input with the same name as your checkbox:</p>
<p><code></p>
<p>
&lt;?php<br />
    &nbsp;&nbsp;&nbsp;&nbsp;// If the box was checked, keep it checked<br />
     &nbsp;&nbsp;&nbsp;&nbsp;if ( isset($_POST['yes']) &#038;&#038; $_POST['yes'] == 'Yes' ) {<br />
         &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;$checked = 'checked="checked"';<br />
     &nbsp;&nbsp;&nbsp;&nbsp;} else {<br />
         &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;$checked = '';<br />
    &nbsp;&nbsp;&nbsp;&nbsp; }<br />
?&gt;
</p>
<p>
&lt;form method="post" action=""&gt;<br />
         &nbsp;&nbsp;&nbsp;&nbsp;&lt;label for="yes"&gt;Yes?&lt;/label&gt;</p>
<p>         &nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Notice both inputs have the same name value --&gt;<br />
         &nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="hidden" value="No" name="yes" /&gt;<br />
         &nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="checkbox" value="Yes" name="yes" &lt;?php echo $checked ?&gt; /&gt;</p>
<p>         &nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="submit" value="submit"&gt;<br />
    &lt;/form&gt;
</p>
<p></code></p>
<p>If the button is left unchecked, the checkbox will return false and $_POST['yes'] will equal the value of the hidden input.  If the box is checked, the value of the checkbox will be returned.  Neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://likesalmon.net/clever-checkbox-handling-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

