<?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>Matt Varone&#187; Matt Varone » Creative Developer  »  Web Design, Web Development &amp; WordPress Articles</title>
	<atom:link href="http://www.mattvarone.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattvarone.com</link>
	<description>Creative Developer</description>
	<lastBuildDate>Sun, 07 Mar 2010 12:47:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
<link>http://www.mattvarone.com</link>
<url>http://www.mattvarone.com/wp-content/mbp-favicon/favicon.ico</url>
<title>Matt Varone</title>
</image>
		<item>
		<title>Query Post And Pages With Multiple Meta Values</title>
		<link>http://www.mattvarone.com/wordpress/query-multiple-meta-values/</link>
		<comments>http://www.mattvarone.com/wordpress/query-multiple-meta-values/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:37:41 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=832</guid>
		<description><![CDATA[— Custom fields give WordPress immense flexibility, by using them correctly you can create very complex applications with the same functionality you could only find in custom CMS. Now for us developers, one of the &#8220;problems&#8221; we might face using multiple custom fields is that there is no easy ( built in ) solution to [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/">Query Post And Pages With Multiple Meta Values</a></p>
]]></description>
			<content:encoded><![CDATA[<p>— Custom fields give WordPress immense flexibility, by using them correctly you can create very complex applications with the same functionality you could only find in custom CMS. Now for us developers, one of the &#8220;problems&#8221; we might face using multiple custom fields is that there is no easy ( built in ) solution to query posts or pages based on these multiple values. If you want to do so you have to create a custom ( somewhat complex ) sql query which is clearly not an easy task for most people, and most important it ain&#8217;t a flexible solution you could just include from one project to another.<br />
<span id="more-832"></span><br />
So in the look out for a nice and solid solution I came across this post by  <a rel="friend" href="http://idealienstudios.com/about/">Jamie Oastler</a> a fellow designer who was kind enough to publish this <strong>amazing</strong> function: <a rel="nofollow" href="http://idealienstudios.com/blog/wordpress/custom-field-query-quandry/"><strong>get_post_meta_multiple</strong></a>.<br />
I really encourage you to go ahead and read his post as he makes an excellent and clear explanation of how the function works and how to implement it in your project.</p>
<p>As good as it is, I found that I still needed a bit more flexibility to use it in my projects so I went ahead and made a few small improvements that others might find useful. These give you the option to make your query even more specific, you can:</p>
<ol class="normal">
<li>Select whether you want to retrieve only posts or pages.</li>
<li>Pass a number ( or many numbers ) to select posts only from specific categories.</li>
<li>Limit the number of posts you want to retrieve.</li>
</ol>
<p><br/></p>
<div class="post-box"><small>&rarr; <strong>Get Post Meta Multiple</strong> Modified Function:<a href="http://lab.mattvarone.com/projects/wordpress/getpostmetamultiple.zip"> &darr;  Download</a></small></div>
<h3>Usage Example</h3>
<p>The usage of the function is really simple, as stated before Jamie made an excellent explanation on his blog, so no need to repeat all of that here again.  The three new values I added can be assigned easily when calling the function as you can find in the example bellow:</p>
<pre class="brush: php">

&lt;?php

/*
Function variables:

$aMetaDataList(array) example: array(&#039;meta_key&#039; =&gt; &#039;meta_value&#039;,&#039;meta_key_2&#039; =&gt; &#039;meta_value_2 )
$szType(string) = &quot;post&quot; or &quot;page&quot;
$szCategory(string) = example: &#039;1&#039; or &#039;1,2,3&#039;
$iLimit(integer)
*/

$aMetaDataList = array(
&#039;custom_field_name_1&#039; =&gt; &#039;Yes&#039;,
&#039;custom_field_name_2&#039; =&gt;&#039;No&#039;,
// etc…
);

$szCategory = &#039;3&#039;; // posts only from category 3
$iLimit = 6; // get only 6 posts

$my_posts = get_post_meta_multiple( $aMetaDataList, &#039;post&#039;, $szCategory, $iLimit );

// Once you have the posts just loop trough them as you would do usually

if ($my_posts):
foreach( $my_posts as $post ):

setup_postdata($post);

the_title();

endforeach;
endif;

?&gt;
</pre>
<p>As you can see its very easy to use and it gives us developers huge flexibility to create amazing stuff. Props to Jamie for his great work. Hope you found this useful, if you have any suggestions please feel free to leave it on the comments, thank you!</p>
<h3>The Function</h3>
<pre class="brush: php">

&lt;?php
function get_post_meta_multiple( $aMetaDataList = array(), $szType = &#039;post&#039;, $szCategory = NULL, $iLimit = NULL )
{
global $wpdb;

$szQuerystr = &quot;SELECT p.* FROM $wpdb-&gt;posts AS p&quot;;

if ( $szCategory != NULL AND is_string($szCategory) )
{
$szQuerystr .= &quot; LEFT JOIN $wpdb-&gt;term_relationships ON (p.ID = $wpdb-&gt;term_relationships.object_id) &quot;;
$szQuerystr .= &quot; LEFT JOIN $wpdb-&gt;term_taxonomy ON ($wpdb-&gt;term_relationships.term_taxonomy_id = $wpdb-&gt;term_taxonomy.term_taxonomy_id) &quot;;
}

$szQuerystr .=  &quot;WHERE p.ID IN ( &quot;;

$szQuerystr .= &quot;SELECT post_id FROM $wpdb-&gt;postmeta WHERE &quot;;

$aInnerqry = array();

foreach($aMetaDataList as $szKey =&gt; $szValue)
{
$aInnerqry[] = $wpdb-&gt;prepare( &quot;(meta_key = %s AND meta_value = %s)&quot;, $szKey, $szValue );
}

$szQuerystr .= implode(&quot; OR &quot;, $aInnerqry);

$szQuerystr .= &quot; GROUP BY post_id &quot;;
$szQuerystr .= &quot;HAVING count(*) = &quot; . count($aMetaDataList);

$szQuerystr .= &quot;) AND p.post_status = &#039;publish&#039; AND p.post_type = &#039;&quot;.$szType.&quot;&#039;&quot;;

if ( $szCategory != NULL AND is_string($szCategory) )
$szQuerystr .= &quot; AND $wpdb-&gt;term_taxonomy.term_id IN(&quot;.$szCategory.&quot;)&quot;;

$szQuerystr .= &quot; ORDER BY p.post_title ASC&quot;;

if ( $iLimit != NULL AND is_int($iLimit) )
$szQuerystr .= &quot; LIMIT &quot;.$iLimit;

$aMetaResults = $wpdb-&gt;get_results($szQuerystr, OBJECT);

return $aMetaResults;
}
?&gt;
</pre>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/">Query Post And Pages With Multiple Meta Values</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/" title="Useful custom functions for WordPress (November 11, 2008)">Useful custom functions for WordPress</a> (64)</li>
	<li><a href="http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/" title="Taking Advantage of Functions.php in WordPress Themes (October 23, 2008)">Taking Advantage of Functions.php in WordPress Themes</a> (43)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/query-multiple-meta-values/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dynamic To Top WordPress Plugin</title>
		<link>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/</link>
		<comments>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 00:36:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[INTERFACE DESIGN]]></category>
		<category><![CDATA[LAYOUT]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PLUGINS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=778</guid>
		<description><![CDATA[&#8212; After some requests I decided to update* and wrap UItoTop into a plugin for WordPress.  This plugin  automatically adds a dynamic &#8220;To Top&#8221; button to easily scroll long pages back to the top. This way  is much more simple to add the functionality to a theme as it only involves uploading [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/">Dynamic To Top WordPress Plugin</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; After some requests I decided to update* and wrap <a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/" title="jQuery Dynamic Scroll to Top">UItoTop</a> into a plugin for WordPress.  This plugin <strong> automatically adds a dynamic &#8220;To Top&#8221; button to easily scroll long pages back to the top</strong>. This way  is much more simple to add the functionality to a theme as it only involves uploading and activating the plugin.</p>
<div class="post-box"><small>→ Dynamic To Top: <a href="http://wordpress.org/extend/plugins/dynamic-to-top/">Plugin on WordPress Website</a> | <a href="http://downloads.wordpress.org/plugin/dynamic-to-top.zip">↓ Download</a></small></div>
<h3>Installation</h3>
<ol class="normal">
<li><strong>Download &#8220;Dynamic To Top&#8221;</strong> from the link above and <strong>unzip the files</strong> somewhere on your computer.</li>
<li><strong>Upload &#8220;dynamic-to-top&#8221; folder</strong> into your plugins directory.</li>
<li><strong>Activate</strong> the plugin.</li>
<li>Have fun!</li>
</ol>
<p><em>* Big thanks to Rémy Tourbiez for his contribution to the code.</em></p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/">Dynamic To Top WordPress Plugin</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/" title="UItoTop jQuery Plugin (September 3, 2009)">UItoTop jQuery Plugin</a> (6)</li>
	<li><a href="http://www.mattvarone.com/wordpress/scrnshotsrss-plugin-update-2/" title="ScrnshotsRSS plugin 2.0 update (November 10, 2008)">ScrnshotsRSS plugin 2.0 update</a> (2)</li>
	<li><a href="http://www.mattvarone.com/web-design/daily-calendar-dates-with-css/" title="Daily Calendar Dates With CSS (September 23, 2008)">Daily Calendar Dates With CSS</a> (6)</li>
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/web-design/website-revamped/" title="Website revamped! (June 22, 2008)">Website revamped!</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WordPress: Output Clean and Valid HTML Content</title>
		<link>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/</link>
		<comments>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 12:39:47 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ACCESSIBILTY]]></category>
		<category><![CDATA[HTML and XHTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RESOURCES]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=770</guid>
		<description><![CDATA[&#8212; I found that more than often clients generate a lot of garbage html in the post content with things like divs, p , a, etc. tags which haven&#8217;t been closed or opened properly. This makes the website fail to validate against W3C standards which in between other things, could potentially affect the site&#8217;s ranking [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/">WordPress: Output Clean and Valid HTML Content</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; I found that more than often clients generate a lot of garbage html in the post content with things like <em>divs</em>, <em>p</em> , <em>a</em>, etc. tags which haven&#8217;t been closed or opened properly. This makes the website fail to validate against W3C standards which in between other things, could potentially affect the site&#8217;s ranking and its accessibility. Of course asking clients to switch to the HTML view to clean the content is out of the question, so a solution is needed, and been that this could happen to any site makes it something that we should take in count upfront when building a professional website.  </p>
<div class="post-box"><small>→ Clean The Content Function: <a href="http://lab.mattvarone.com/demos/clean/mattvarone-cleanwpcontent.zip">↓ Download</a> </small></div>
<p><span id="more-770"></span></p>
<p>After some research on the subject I found <strong><a href="http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php">htmLawed</a></strong>, a PHP code to purify and filter HTML that works incredibly well. Props to the htmLawed team for their awesome work!. To merge it with WordPress I wrote a little function which automatically filters the content coming from the post. The results are amazing, htmLawed cleans and filters all the bad content and makes the pages validate again right away!</p>
<pre class="brush: php">
	include_once ( TEMPLATEPATH . &#039;/htmLawed.php&#039; ); // THIS FILE SHOULD RESIDE IN THE THEME FOLDER.

	function clean_the_content( $content )
	{
		$szPostContent = $content;
		$szRemoveFilter = array( &quot;~&lt;p[^&gt;]*&gt;\s?&lt;/p&gt;~&quot;, &quot;~&lt;a[^&gt;]*&gt;\s?&lt;/a&gt;~&quot;, &quot;~&lt;font[^&gt;]*&gt;~&quot;, &quot;~&lt;\/font&gt;~&quot;, &quot;~&lt;span[^&gt;]*&gt;\s?&lt;/span&gt;~&quot; );
		$szPostContent = preg_replace( $szRemoveFilter, &#039;&#039; , $szPostContent);
		$szPostContent = htmLawed($szPostContent);
		return $szPostContent;
	}

	add_filter(&#039;the_content&#039;, &#039;clean_the_content&#039;);
</pre>
<p>To use this function simple drop the two files in your theme directory and you are set to go!. Hope you find this post useful. Cheers!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/">WordPress: Output Clean and Valid HTML Content</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/useful-functions-for-wordpress/" title="Useful custom functions for WordPress (November 11, 2008)">Useful custom functions for WordPress</a> (64)</li>
	<li><a href="http://www.mattvarone.com/wordpress/functionsphp-wordpress-themes/" title="Taking Advantage of Functions.php in WordPress Themes (October 23, 2008)">Taking Advantage of Functions.php in WordPress Themes</a> (43)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>UItoTop jQuery Plugin</title>
		<link>http://www.mattvarone.com/web-design/uitotop-jquery-plugin/</link>
		<comments>http://www.mattvarone.com/web-design/uitotop-jquery-plugin/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 14:11:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[INTERFACE DESIGN]]></category>
		<category><![CDATA[JQUERY]]></category>
		<category><![CDATA[PLUGINS]]></category>
		<category><![CDATA[RESOURCES]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=763</guid>
		<description><![CDATA[
 Current version: 1.1 3/4/10
— Inspired by the great idea of David Walsh&#8217;s  jQuery topLink Plugin, I made a similar plugin but with two key differences, this one does not require you to add extra html markup or extra plugins to function. It will only work when JavaScript is turned on ( on purpose [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/">UItoTop jQuery Plugin</a></p>
]]></description>
			<content:encoded><![CDATA[<p><img class="border aligncenter size-full wp-image-765" title="uitotop" src="http://www.mattvarone.com/wp-content/uploads/2009/09/uitotop.jpg" alt="uitotop" width="560" height="134" /></p>
<p class="message-box info"> Current version: <strong>1.1</strong> <small>3/4/10</small></p>
<p>— Inspired by the great idea of David Walsh&#8217;s <a href="http://davidwalsh.name/jquery-top-link/"> jQuery topLink Plugin</a>, I made a similar plugin but with two key differences, this one does not require you to add extra html markup or extra plugins to function. It will only work when JavaScript is turned on ( on purpose ), It&#8217;s easy to setup with only one line of code, and it works cross-browser nicely ( Tested: IE6-8, FF, Safari ). Optionally it can benefit from the <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery Easing plugin</a> with a different easing animation for the page scrolling.</p>
<div class="post-box"><small>→ UItoTop: <a href="http://lab.mattvarone.com/projects/jquery/totop/">View the demo</a> | <a href="http://lab.mattvarone.com/projects/jquery/totop/jquery.ui.totop.zip">↓ Download</a> </small></div>
<p><span id="more-763"></span></p>
<h3>RELEASE NOTES</h3>
<p><strong>ver 1.1</strong> &#8211; Improvements to configuration conveniences. *<br />
<strong>ver 1.0</strong> &#8211; First Release.</p>
<p><em>* Big thanks to Rémy Tourbiez for this contribution to the code.</em></p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/web-design/uitotop-jquery-plugin/">UItoTop jQuery Plugin</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/scrnshots-plugin-for-wordpress/" title="ScrnshotsRSS: Scrnshots.com Plugin For Wordpress (October 8, 2008)">ScrnshotsRSS: Scrnshots.com Plugin For Wordpress</a> (25)</li>
	<li><a href="http://www.mattvarone.com/wordpress/scrnshotsrss-plugin-update-2/" title="ScrnshotsRSS plugin 2.0 update (November 10, 2008)">ScrnshotsRSS plugin 2.0 update</a> (2)</li>
	<li><a href="http://www.mattvarone.com/icon/free-mini-calendar-icons-set/" title="Free Mini Calendar Icons Set (September 20, 2008)">Free Mini Calendar Icons Set</a> (9)</li>
	<li><a href="http://www.mattvarone.com/icon/free-daily-calendar-icons-set-for-css/" title="Free Daily Calendar Icons Set For CSS (September 22, 2008)">Free Daily Calendar Icons Set For CSS</a> (19)</li>
	<li><a href="http://www.mattvarone.com/wordpress/dynamic-to-top-wordpress-plugin/" title="Dynamic To Top WordPress Plugin (March 4, 2010)">Dynamic To Top WordPress Plugin</a> (12)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/web-design/uitotop-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>SimpleForm: Easy PHP multi-form email handler</title>
		<link>http://www.mattvarone.com/web-design/simpleform-php-email-script/</link>
		<comments>http://www.mattvarone.com/web-design/simpleform-php-email-script/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 18:49:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Design & Development]]></category>
		<category><![CDATA[FORMS]]></category>
		<category><![CDATA[MAIL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=705</guid>
		<description><![CDATA[— It&#8217;s been a while, but today I am releasing a new version of my contact form script, this time under the name SimpleForm. It&#8217;s a nicer version of the previous one, re-written from the ground up and with a couple of new features. SimpleForm is basically meant to be an easy solution to handle [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/web-design/simpleform-php-email-script/">SimpleForm: Easy PHP multi-form email handler</a></p>
]]></description>
			<content:encoded><![CDATA[<p>— It&#8217;s been a while, but today I am releasing a new version of my <a href="http://www.mattvarone.com/web-design/php-contact-form-script/" title="contact form script" >contact form script</a>, this time under the name <strong>SimpleForm</strong>. It&#8217;s a nicer version of the previous one, re-written from the ground up and with a couple of new features. SimpleForm is basically meant to be an <strong>easy solution to handle one or many forms with little effort</strong>. It&#8217;s mainly focused on ease of use and rapid deployment.</p>
<p><img src="http://www.mattvarone.com/wp-content/uploads/2009/04/simpleform.jpg" alt="simpleform" title="simpleform" width="560" height="134" class="aligncenter border" /></p>
<p class="message-box info"> Current version: <strong>1.1.4</strong> <small>7/31/09</small>  </p>
<h4>These are a couple of it&#8217;s main features <strong>( ver. 1.1.4 )</strong>:</h4>
<p>* Multiform handler.<br />
* Support for required fields.<br />
* PHP <a href="http://www.linuxjournal.com/article/9585" title="email validation" >email validation</a>.<br />
* Unobtrusive JavaScript function to pre-check form data ( 4KB file ).<br />
* Lightweight, easy to use.<br />
* Multilingual support.<br />
* External configuration file that can reside outside the public folder.</p>
<div class="post-box"><small>→ SimpleForm: <a href="http://lab.mattvarone.com/demos/simpleform/">View the demo</a> | <a href="http://lab.mattvarone.com/demos/simpleform/multiple.php" title="Mutiple Forms">Mutiple Forms</a> | <a href="http://lab.mattvarone.com/demos/simpleform/simpleform.1.1.4.zip">↓ Download</a> </small></div>
<h3>HOW DOES IT WORKS?</h3>
<p>It&#8217;s very simple, first there is a configuration file where you define all of your website forms, by this I mean form title, form fields, form required fields and the location of each form. Then there are some snippets you have to add to your form page/s and thats all. SimpleForm takes care of pre-cheking the form fields with JS and then validating them with PHP, if it&#8217;s valid then it will send the email to the configured email address and return the user to the form page with a success message or otherwise, with an error message.</p>
<h3>INSTALLING THE SCRIPT</h3>
<h4>These are the necessary steps to have it up and running ( requires PHP 5 ):</h4>
<ol  class="normal">
<li><strong>Download</strong> <a href="http://lab.mattvarone.com/demos/simpleform/simpleform.1.1.4.zip">SimpleForm</a> ( ver 1.1.4 )</li>
<li><strong>Open sf-config.php</strong> and edit the necessary info.</li>
<li><strong>Upload sf-config.php</strong> to your host ( preferably outside the public folder ).</li>
<li>Open <strong>simpleform.php</strong> and edit the variable <em>$PATH_TO_CONFIG_FILE</em> ( on line 24 ) with the path from <em>simpleform.php</em> to <em>sf-config.php</em> ( leave empty if it resides on the same folder ).</li>
<li>Upload<strong> simpleform.php</strong>, <strong>simpleform.css</strong> and <strong>checkform.mini.js</strong> inside your public folder.</li>
<li>Open your form page/s and <strong>add the necessary code snippets</strong>.</li>
</ol>
<p><span id="more-705"></span></p>
<h3>EDITING THE CONFIGURATION FILE SF-CONFIG.PHP</h3>
<pre class="brush: php">
# ------------------------------------------------------------ #
// SIMPLEFORM CONFIGURATION								      //
# ------------------------------------------------------------ #

/* GENERAL CONFIGURATION
/////////////////////////////*/

// The name of the website/client. Example: &quot;My Website&quot;.
$aSettings[&quot;szFrom&quot;] = &quot;&quot;;							

// The email address that will receive the emails. Example: &quot;me@myemail.com&quot;.
$aSettings[&quot;szRecipient&quot;] = &quot;&quot;;		

/* The email address that will be used to send the emails. To work properly this has to be a real account
configured on the same server of the site. Example: &quot;noreply@mywebsite.com&quot;. */
$aSettings[&quot;szFromEmail&quot;] = &quot;&quot;;					    

/* FORMS CONFIGURATION
/////////////////////////////*/

/* The next step is to configure the Form/s.
   You can add as many as you want. */

$aForms = array(

	1 =&gt; array( 									// FORM ID: 1
		&quot;szFormTitle&quot; =&gt; &quot;&quot;,						// FORM TITLE - Example: &quot;Contact Form&quot;
		&quot;szFormURL&quot; =&gt; &quot;&quot;,							// FORM URL ( users will be redirected to this page )
		&quot;szFormRequired&quot; =&gt; array(					/* REQUIRED FIELDS ( array of name attributes ) */
			&quot;name&quot;,
			&quot;email&quot;,
		),
		&quot;aFormFields&quot; =&gt; array( 					/* LIST OF FORM FIELDS AND THEIR OUTPUT NAME
 													  All input fields coming from the form should go here.
													  The first value is the name attribute used and the second value
													  on the right the name displayed on the outputed data.

													  Any required field that contains the word &quot;email&quot; will have
													  it&quot;s value validated as an email address. */
		   	&quot;name&quot; =&gt; &quot;First Name&quot;,
			&quot;email&quot; =&gt; &quot;E-mail&quot;,
			&quot;work_email&quot; =&gt; &quot;Work Email&quot;,
			&quot;phone&quot; =&gt; &quot;Telephone&quot;,
			&quot;-sep1&quot; =&gt; &quot;This is a separator&quot;,		/* This is a separator. Any variable starting with the sign &quot;-&quot;
														will act as a content separator. */
			&quot;color&quot; =&gt; &quot;Color Option&quot;,
			&quot;comments&quot; =&gt; &quot;Comments&quot;,
			&quot;-sep2&quot; =&gt; &quot;This is Another separator&quot;,
			&quot;newsletter&quot; =&gt; &quot;Subscribe to our Newsletter?&quot;,
			&quot;interested[]&quot; =&gt; &quot;Im interested in&quot;,
			/* add more */
			)
	),

	2 =&gt; array(										/* Form 2. Same as above */
		&quot;szFormTitle&quot; =&gt; &quot;&quot;,
		&quot;szFormRequired&quot; =&gt; array(),
		&quot;szFormURL&quot; =&gt; &quot;&quot;,
		&quot;aFormFields&quot; =&gt; array(
			/* add more */
			)
	),

	3 =&gt; array(										/* Form 3. Same as above */
		&quot;szFormTitle&quot; =&gt; &quot;&quot;,
		&quot;szFormRequired&quot; =&gt; array(),
		&quot;szFormURL&quot; =&gt; &quot;&quot;,
		&quot;aFormFields&quot; =&gt; array(
			/* add more */
			)
		),

	/* add more */
);

/* RESPONSE CONFIGURATION
/////////////////////////////*/

/* Response Messages: These are the variables that hold the messages
the system prints as response. You can modify them to suit your project needs. */

 // Form has been sent.
$aSettings[&quot;aMessages&quot;][&quot;szSubmitSucess&quot;]  = &quot;Your message has been sent succesfully. Thanks!&quot;;
// Missing fields.
$aSettings[&quot;aMessages&quot;][&quot;szMissingFields&quot;] = &quot;Please complete all required fields.&quot;;
// Unvalid email address.
$aSettings[&quot;aMessages&quot;][&quot;szUnvalidEmail&quot;]  = &quot;Please insert a valid email address.&quot;;
// Email not sent by system error.
$aSettings[&quot;aMessages&quot;][&quot;szSystemError&quot;]   = &quot;There was an error in the system. Please try again later. Thanks!&quot;;

/* ADVANCED CONFIGURATION
/////////////////////////////*/

// Name of the GET variable to pass response messages
define( &quot;GET_NAME&quot;, &quot;response&quot;);
// Debug mode ( prints email content, and system errors )
define( &quot;DEBUG_MODE&quot; , false );
/* Check if the domain of the submited email addresses exists.
False by default as it may bring problems with some servers. ) */
define( &quot;CHECK_EMAIL_ADDRESS_DNS&quot; , false );
</pre>
<h3>INTEGRATING SIMPLEFORM WITH YOUR FORMS</h3>
<p>Below you&#8217;ll find the things you need to do to your form page ( must be php file ) for SimpleForm to work. I also have included a full example at bottom.</p>
<h4>A. Add  Javascript and CSS files</h4>
<p>	Add <strong>simpleform.css</strong> and<strong> checkform.js</strong> ( or <strong>checkform.mini.js</strong> ) inside the <strong>&lt;head&gt;</strong> element:</p>
<pre class="brush: html">
	&lt;link rel=&quot;stylesheet&quot; href=&quot;simpleform.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot;/&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;checkform.mini.js&quot;&gt;&lt;/script&gt;
	</pre>
<h4>B. Define the path to the config file and Include <strong>simpleform.php</strong> in the document ( before your form/s ):</h4>
<pre class="brush: php">
	&lt;?php
	define( &quot;CONFIG_PATH&quot;, &quot;place/here/the/path/to/sf-congif/dir/&quot; );
	require_once &quot;simpleform.php&quot;;
	$sForm = new simpleForm();
	?&gt;
	</pre>
<h4>C. Add SimpleForm <strong>Responses function</strong></h4>
<p>		   Prints the systems response and can reside anywhere on the document.</p>
<pre class="brush: php">
			&lt;?php
 		   	// Example: &lt;p class=&quot;message-box error&quot;&gt;Please insert a valid email address.&lt;/p&gt;
 		   	$sForm-&gt;handleMessage(); ?
 		   	&gt;
		</pre>
<p>Output example:
<p class="message-box error">Please insert a valid email address.</p>
<h4>D. Add SimpleForm <strong>Form function</strong></h4>
<p> This function generates the required hidden input fields for simpleForm to work. The value passed is the ID assigned to the current form in the configuration file. This function must reside in between the &lt;form&gt;&lt;/form&gt;  elements.</p>
<pre class="brush: php">
 &lt;?php
 //Prints necessary data for the form with the ID = 1
$sForm-&gt;printData(1);
?&gt;
</pre>
<h4>E. Edit the<strong> &lt;form&gt; attributes</strong>:</h4>
<p>	Point the form&#8217;s <em>action attribute</em> to <strong>simpleform.php</strong> and then add the <strong>checkform</strong> function to enable the js data pre-checking.</p>
<pre class="brush: html">

	&lt;form action=&quot;simpleform.php&quot; method=&quot;post&quot; onsubmit=&quot;return checkform(this)&quot;&gt;
</pre>
<p>	The <strong>checkform()</strong> function supports an optional string parameter which alters the text you<br />
want to display on the js alerts. The variable #name is provided as a wildcard for the field Name.</p>
<p>	<strong>Examples:</strong><br />
				&#8220;Please complete the field #name&#8221;<br />
				&#8220;The field #name is missing&#8221;<br />
				&#8220;Por Favor complete el campo #name&#8221;</p>
<pre class="brush: html">
				onsubmit=&quot;return checkform(this,&#039;The field #name is missing&#039;)&quot;
				</pre>
<h4>Full Example</h4>
<pre class="brush: php">
	&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
		&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
		&lt;head&gt;
			&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
			&lt;title&gt;SimpleForm Example&lt;/title&gt;
			&lt;link rel=&quot;stylesheet&quot; href=&quot;simpleform.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot;/&gt;
			&lt;script type=&quot;text/javascript&quot; src=&quot;checkform.mini.js&quot;&gt;&lt;/script&gt;
		&lt;/head&gt;
		&lt;body&gt;

			&lt;?php
			define( &quot;CONFIG_PATH&quot;, &quot;../secure/&quot; );

			require_once &quot;simpleform.php&quot;;
			$sForm = new simpleForm();

			$sForm-&gt;handleMessage();
			?&gt;

			&lt;form action=&quot;simpleform.php&quot; method=&quot;post&quot; onsubmit=&quot;return checkform(this)&quot;&gt;
		 	&lt;fieldset&gt;
		 	&lt;?php $sForm-&gt;printData(1); ?&gt;
				&lt;legend&gt;Personal Details:&lt;/legend&gt;
		        &lt;label for=&quot;name&quot; &gt;Name&lt;/label&gt;
		        &lt;input name=&quot;name&quot; id=&quot;name&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;
		        &lt;label for=&quot;email&quot;&gt;Email &lt;span class=&quot;required&quot;&gt;(required)&lt;/span&gt;&lt;/label&gt;
		        &lt;input name=&quot;email&quot; id=&quot;email&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;
				&lt;label for=&quot;work_email&quot;&gt;Work Email&lt;/label&gt;
		        &lt;input name=&quot;work_email&quot; id=&quot;work_email&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;
				&lt;label for=&quot;phone&quot;&gt;Telephone &lt;span class=&quot;required&quot;&gt;(required)&lt;/span&gt;&lt;/label&gt;
		        &lt;input name=&quot;phone&quot; id=&quot;phone&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;
		        &lt;label for=&quot;color&quot;&gt;Color Options: &lt;span class=&quot;required&quot;&gt;(required)&lt;/span&gt;&lt;/label&gt;
		        &lt;select name=&quot;color&quot; id=&quot;color&quot;&gt;
					&lt;option value=&quot;-&quot;&gt;Choose a color&lt;/option&gt;
					&lt;option value=&quot;Red&quot;&gt;Red&lt;/option&gt;
					&lt;option value=&quot;Green&quot;&gt;Green&lt;/option&gt;
					&lt;option value=&quot;Blue&quot;&gt;Blue&lt;/option&gt;
				&lt;/select&gt;
		        &lt;label for=&quot;comments&quot;&gt;Comments&lt;/label&gt;
		        &lt;textarea name=&quot;comments&quot; id=&quot;comments&quot; rows=&quot;10&quot; cols=&quot;50&quot;&gt;&lt;/textarea&gt;
		        &lt;/fieldset&gt;
		        &lt;fieldset class=&quot;radio&quot;&gt;
		            &lt;legend&gt;Subscribe to our Newsletter? &lt;span class=&quot;required&quot;&gt;(required)&lt;/span&gt;&lt;/legend&gt;
		            &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;newsletter&quot; value=&quot;Yes&quot; /&gt; Yes&lt;/label&gt;
		            &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;newsletter&quot; value=&quot;No&quot; /&gt; No&lt;/label&gt;
		        &lt;/fieldset&gt;
				&lt;fieldset class=&quot;checkbox&quot;&gt;
		            &lt;legend&gt;Im interested in: &lt;span class=&quot;required&quot;&gt;(required)&lt;/span&gt;&lt;/legend&gt;
		            &lt;label&gt;&lt;input type=&quot;checkbox&quot; name=&quot;interested[]&quot; value=&quot;Arts&quot; /&gt; Arts&lt;/label&gt;
					&lt;label&gt;&lt;input type=&quot;checkbox&quot; name=&quot;interested[]&quot; value=&quot;Science&quot; /&gt; Science&lt;/label&gt;
					&lt;label&gt;&lt;input type=&quot;checkbox&quot; name=&quot;interested[]&quot; value=&quot;Sports&quot; /&gt; Sports&lt;/label&gt;
		        &lt;/fieldset&gt;

		        &lt;p&gt;&lt;button type=&quot;submit&quot;&gt;Submit this!&lt;/button&gt;&lt;/p&gt;
		    &lt;/form&gt;

		&lt;/body&gt;
		&lt;/html&gt;
</pre>
<div class="post-box"><small>→ SimpleForm: <a href="http://lab.mattvarone.com/demos/simpleform/">View the demo</a> | <a href="http://lab.mattvarone.com/demos/simpleform/multiple.php" title="Mutiple Forms">Mutiple Forms</a> | <a href="http://lab.mattvarone.com/demos/simpleform/simpleform.1.1.2.zip">↓ Download</a> </small></div>
<h3>RELEASE NOTES</h3>
<p><strong>ver 1.1.4</strong> &#8211; Another Email Bug fixed ( Courtesy of megabonez ).<br />
<strong>ver 1.1.3</strong> &#8211; Email Bug fixed ( Mayor thanks to Jim from <a href="http://www.cpscreative.com">cpscreative.com</a> ).<br />
<strong>ver 1.1.2</strong> &#8211; Minor Bugs fixed.<br />
<strong>ver 1.1.1</strong> &#8211; Optional Email DNS checking.<br />
<strong>ver 1.1</strong> &#8211; Easier path deployment, Configurable response variable name, Debug function and minor bug fixes.<br />
<strong>ver 1.0</strong> &#8211; First Release.</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/web-design/simpleform-php-email-script/">SimpleForm: Easy PHP multi-form email handler</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/web-design/php-contact-form-script/" title="PHP Contact form script (September 16, 2008)">PHP Contact form script</a> (5)</li>
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/web-design/ternary-conditionals-in-php/" title="Ternary Conditionals in PHP (October 25, 2008)">Ternary Conditionals in PHP</a> (5)</li>
	<li><a href="http://www.mattvarone.com/wordpress/scrnshotsrss-plugin-update-2/" title="ScrnshotsRSS plugin 2.0 update (November 10, 2008)">ScrnshotsRSS plugin 2.0 update</a> (2)</li>
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/web-design/simpleform-php-email-script/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
		<item>
		<title>Custom WordPress function to check page parent</title>
		<link>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/</link>
		<comments>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:39:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TEMPLATE FUNCTIONS]]></category>

		<guid isPermaLink="false">http://www.mattvarone.com/?p=694</guid>
		<description><![CDATA[&#8212; Quick update to the is_subpage() function. Basically it&#8217;s does the same but now it also accepts an integer to check if the current page is a child of certain ID. This way its easier to track if  the current location is a subpage of a certain page. If it matches it will return [...]<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/wordpress-check-page-parent/">Custom WordPress function to check page parent</a></p>
]]></description>
			<content:encoded><![CDATA[<p>&mdash; Quick update to the <a href="http://www.mattvarone.com/wordpress/is_subpage-function/">is_subpage() function</a>. Basically it&#8217;s does the same but now it also accepts an integer to check if the current page is a child of certain ID. This way its easier to track if  the current location is a subpage of a certain page. If it matches it will return a <strong>true</strong> value otherwise, it will be <strong>false</strong>.</p>
<div class="post-box"><small>→  Download <a href="http://lab.mattvarone.com/demos/wp-functions/functions-part4.zip">the function here</a></small></div>
<pre class="brush: php">
function is_subpage( $iID = null )
	{
		global $post, $wpdb;

		if ( is_page() AND isset( $post-&gt;post_parent ) != 0 )
		{
			$aParent = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT ID FROM $wpdb-&gt;posts WHERE ID = %d AND post_type = &#039;page&#039; LIMIT 1&quot;, $post-&gt;post_parent ) );

			if ( is_int( $iID ) &gt; 0 )
				if ( $aParent-&gt;ID == $iID ) return true; else return false;
			else
				if ( $aParent-&gt;ID )	return true; else return false;

		}
		else
		{
			return false;
		}
	}

/* EXAMPLE */

if ( is_page(&#039;producs&#039;) OR is_subpage( 8 ) )
{
  //do something
};
</pre>
<p>Cheers!</p>
<p>This is a post from: <a href="http://www.mattvarone.com">Matt Varone</a><br/><br/><a href="http://www.mattvarone.com/wordpress/wordpress-check-page-parent/">Custom WordPress function to check page parent</a></p>

	<h4 class="related">Somewhat related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.mattvarone.com/wordpress/output-clean-valid-xhtml/" title="WordPress: Output Clean and Valid HTML Content (October 30, 2009)">WordPress: Output Clean and Valid HTML Content</a> (10)</li>
	<li><a href="http://www.mattvarone.com/wordpress/query-multiple-meta-values/" title="Query Post And Pages With Multiple Meta Values (March 5, 2010)">Query Post And Pages With Multiple Meta Values</a> (3)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-recent-posts-in-wordpress/" title="List recent posts in WordPress (September 15, 2008)">List recent posts in WordPress</a> (4)</li>
	<li><a href="http://www.mattvarone.com/wordpress/list-users/" title="Custom Query: List WordPress Users (November 19, 2008)">Custom Query: List WordPress Users</a> (68)</li>
	<li><a href="http://www.mattvarone.com/wordpress/add-css-javascript-wordpress-theme/" title="Correct way of adding CSS and Javascript references to WordPress themes (October 5, 2008)">Correct way of adding CSS and Javascript references to WordPress themes</a> (11)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.mattvarone.com/wordpress/wordpress-check-page-parent/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
